-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·77 lines (63 loc) · 1.47 KB
/
cli.js
File metadata and controls
executable file
·77 lines (63 loc) · 1.47 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env node
'use strict';
var Liftoff = require('liftoff');
var subarg = require('subarg');
// applies only to top level command
var argOptions = {
'boolean': [ 'watch', 'production' ],
alias: {
w: [ 'watch' ],
},
'default': {
watch: false,
production: false,
},
};
var argv = subarg(process.argv.slice(2), argOptions);
var cli = new Liftoff({
name: 'jager',
configName: 'jagerfile',
extensions: {
'.js': null,
},
});
cli.launch({}, function(env) {
var jager = require(env.modulePath);
var tasks = [];
var production = process.env.NODE_ENV === 'production'
|| argv.production === true
|| argv.env === 'production';
if (env.configPath) {
require(env.configPath);
tasks = argv._.length ? argv._ : ['default'];
} else if (argv.preset) {
var presets = Array.isArray(argv.preset) ? argv.preset : [argv.preset];
presets.forEach(function(preset) {
var name;
if (typeof preset === 'string') {
name = preset;
} else if (preset.name) {
name = preset.name;
delete preset.name;
} else if (preset._ && preset._.length) {
name = preset._.shift();
} else {
throw new Error('Invalid preset name');
}
var options = preset;
delete options._;
var watch = (!!preset.watch) || argv.watch;
delete preset.watch;
jager.preset(name, options);
if (watch) {
tasks.push(name + ':watch');
} else {
tasks.push(name);
}
});
}
jager.run(tasks, {
debug: argv.debug === true,
production: production,
});
});