forked from os-js/OS.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosjs
executable file
·47 lines (39 loc) · 1.08 KB
/
osjs
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
#!/usr/bin/env node
(function(_build, _utils, _minimist) {
'use strict';
function done(err) {
process.exit(err ? 1 : 0);
}
if ( process.argv.length < 3 ) {
console.error('Not enough arguments.')
return done(true);
}
var args = _minimist(process.argv.slice(2));
var actions = args._.map(function(iter) {
var action = iter.trim().split(':');
var task = action[0];
var arg = action[1];
if ( !_build[task] ) {
console.error('Invalid task', task);
done(true);
}
return [task, arg]
});
process.on('uncaughtException', function(error) {
console.error('An uncaught exception occured', error);
console.error(error.stack);
done(true);
});
_utils.iterate(actions, function(action, idx, next) {
_build[action[0]]({
option: function(k) {
return args[k];
}
}, action[1], function(err) {
if ( err ) {
return done(err);
}
next();
});
}, done);
})(require(__dirname + '/src/build/index.js'), require(__dirname + '/src/build/utils.js'), require('minimist'), require('colors'));