forked from JKHeadley/rest-hapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest-hapi-cli.js
executable file
·63 lines (54 loc) · 1.16 KB
/
rest-hapi-cli.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/env node
let userArgs = process.argv.slice(2)
let command = userArgs[0]
let args = userArgs
args.shift()
let exec = require('child_process').exec
let isWindows = /^win/.test(process.platform)
let cmdString = '$PWD/node_modules/rest-hapi/scripts/'
if (isWindows) {
cmdString = './node_modules/rest-hapi/scripts/'
}
switch (command) {
case 'seed':
exec('node ' + cmdString + 'seed.js ' + args, function(
err,
stdout,
stderr
) {
console.log(stdout)
console.log(stderr)
if (err) {
throw err
}
})
break
case 'test':
exec('npm run test', function(err, stdout, stderr) {
console.log(stdout)
console.log(stderr)
if (err) {
throw err
}
})
break
case 'update-associations':
exec(
'node ' +
cmdString +
'update-associations.js' +
' --options ' +
args.join(' --options '),
function(err, stdout, stderr) {
console.log(stdout)
console.log(stderr)
if (err) {
throw err
}
}
)
break
default:
console.error('error, unknown command:', command)
break
}