-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvagrant.js
48 lines (45 loc) · 1.08 KB
/
vagrant.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const exec = require("child_process").exec
exports = module.exports = {
box_add: function(box, callback) {
this.box_exists(box.boxname, (result) => {
if (result === true) {
callback(null)
return
} else {
let command = `vagrant box add ${box.boxname} ${box.box_path}`
exec(command, (error, stdout, stderr) => {
if (stderr) {
console.info(stderr)
}
if (error == null) {
callback(null)
} else {
throw error
}
})
}
})
},
box_exists: function(boxname, callback) {
let command = `vagrant box list | grep ${boxname}`
exec(command, (error, stdout, stderr) => {
if (error == null) {
if (stdout == "") {
callback(false)
} else {
callback(true)
}
} else {
callback(false)
}
})
},
up: function(box, callback) {
let option = {
cwd: `./vagrant/${box.basename}`,
}
exec("vagrant up", option, (error, stdout, stderr) => {
callback(null)
})
},
}