-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·44 lines (37 loc) · 914 Bytes
/
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
#!/usr/bin/env node
var ui = require("./lib/ui");
function mandatory (ok, msg) {
if (ok) return;
ui.log(ui.color.red("Error") + ": " + msg);
process.exit(1);
}
function main (config) {
if (!config.files) config.files = [];
// parse argv
var arg, key;
while (
arg = config.argv.shift()
) if (
"--" === arg.substr(0, 2)
) {
if (key) config[key] = true;
key = arg.substr(2);
} else if (key) {
config[key] = arg;
key = null;
} else config.files.push(arg);
if (key) config[key] = true;
delete config.argv;
config.port = parseInt(config.port);
config.root = "/";
config.path = process.cwd().substr(1);
require("./lib/app").boot(config);
}
if (process.argv[1].match(/yeti|cli\.js/)) {
main({
port : 8000,
argv : process.argv.slice(2)
});
} else {
exports.main = main;
}