forked from node-cube/cube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcube-start
executable file
·35 lines (32 loc) · 1.01 KB
/
cube-start
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
#!/usr/bin/env node
'use strict';
const path = require('path');
const cmd = require('commander');
const Cube = require('../index');
cmd
.option('-b, --base [value]', 'the http virtual base, i.e `http://static.taobao.com/res/js/`, base -> `/res/js/`')
.option('-p, --processors [value]', 'the external processors')
.option('-P, --port [value]', 'server port')
.option('-r, --resbase [value]', 'set the http base path for resourcs')
.option('-R, --remote [value]', 'set remote option')
.option('-o, --output [value]', 'output dir')
.option('--builded', 'if root path is builded-code')
.parse(process.argv);
let args = cmd;
let rootPath = cmd.args[0];
let processors;
if (args.processors) {
processors = args.processors.split(',');
} else {
processors = [];
}
Cube.init({
root: path.join(process.cwd(), rootPath || ''),
port: args.port ? args.port : 9999,
router: args.vpath || '/',
processors: processors,
resBase: args.resbase,
remote: args.remote,
middleware: false,
builded: args.builded
});