-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·57 lines (49 loc) · 1.23 KB
/
index.js
File metadata and controls
executable file
·57 lines (49 loc) · 1.23 KB
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
50
51
52
53
54
55
56
57
#!/usr/bin/env node
require('./bootstrap');
const yargs = require('yargs');
const { pkginfo, middleware, response } = require('@/lib');
const mainBinName = pkginfo.getMainBinName();
let program;
program = yargs
.commandDir('cmds')
.recommendCommands(true)
.example(`
1. 可以通过 ${mainBinName} subcommand -h 查看子命令的详细帮助
`)
.option('env', {
alias: 'e',
describe: '运行时环境',
choices: ['unittest', 'local', 'staging', 'preview', 'production'],
type: 'string',
default: 'production',
})
.option('debug', {
alias: 'd',
describe: '是否是调试模式(打开所有日志)',
type: 'boolean',
default: false,
})
.option('verbose', {
alias: 'V',
describe: '打印命令的详细执行过程',
type: 'boolean',
default: false,
})
.demandCommand(1, '请至少提供一个命令!')
.scriptName(mainBinName)
.options({
help: {
alias: 'h',
describe: '查看帮助信息',
},
version: {
alias: 'v',
describe: '查看当前版本',
},
});
program.middleware(middleware);
// eslint-disable-next-line no-unused-expressions
program.argv;
process.on('uncaughtException', (e) => {
response.fatal(e, 1023, 1);
});