forked from CoderDojo/cp-local-development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocaldev.js
executable file
·41 lines (36 loc) · 1.13 KB
/
localdev.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
#!/usr/bin/env node
var system = require('./system.js');
var _ = require('lodash');
function usage () {
console.log('Usage "./localdev.js <command>" where command is one of: ');
console.log(' "init <system>": does a fresh setup of your local dev environment');
console.log(' "run <system>": runs all the services in your system');
console.log(' "testdata <system>": loads test data for each service');
process.exit;
}
function main (cb) {
var argv = require('minimist')(process.argv.slice(2));
var command = argv._[0];
if (!command) return usage();
switch (command) {
case 'init':
require('./init.js')(argv, system, cb);
break;
case 'run':
require('./run.js')(argv, system, cb);
break;
case 'testdata':
require('./testdata.js')(argv, system, cb);
break;
default:
return cb('unknown command: ' + command);
}
}
main(function (err, output) {
if (err) return console.error(err);
if (output && typeof output === 'string') return console.log(output);
var out = _.filter(_.flatten(output), function (o) {
if (o) return o;
});
console.log(out.join('\n'));
});