-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·49 lines (41 loc) · 1.13 KB
/
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
45
46
47
48
49
#!/usr/bin/env node
var program = require('commander');
var SPMServer = require('./');
var join = require('path').join;
program
.version(require('./package').version, '-v, --version')
.option('-p, --port <port>', 'server port, default: 8000')
.option('-b, --base <path>', 'set seajs\'s base')
.option('--proxy', 'enable anyproxy on 8989')
.option('--livereload', 'enable livereload')
.option('--weinre', 'enable weinre')
.option('--cache', 'enable 304 cache for spm')
.option('--cdn <cdn>', 'cdn proxy, defaults: https://115.238.23.196^a.alipayobjects.com')
.parse(process.argv);
var cwd = process.cwd();
var args = program.args;
if (args.length === 1) {
cwd = join(cwd, args[0]);
}
var s = new SPMServer(cwd);
s.combo();
s.directory();
var spmOpts = {
base: program.base,
cache: program.cache
};
if (args.length > 1) {
args.forEach(function(root) {
s.spm(join(cwd, root), spmOpts);
});
} else {
s.spm(spmOpts);
}
s.cdn({
proxy: program.cdn && program.cdn.split('^')
});
s.static();
s.listen(program.port || 8000);
if (program.livereload) s.livereload();
if (program.proxy) s.proxy();
if (program.weinre) s.weinre();