-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·42 lines (34 loc) · 835 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
#!/usr/bin/env node
function configure (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);
return config;
}
function main (config) {
require("./lib/app").boot(configure(config));
}
if (process.argv[1].match(/yeti|cli\.js/)) {
main({
port : 8000,
argv : process.argv.slice(2)
});
} else {
exports.configure = configure;
}