-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·74 lines (59 loc) · 1.29 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
const program = require('commander');
const emoji = require('node-emoji');
const chalk = require('chalk');
const {
dev,
prod,
lint,
init,
} = require('./bin');
const { checkDir } = require('./util');
program
.version(require('./package.json').version)
.description('Small and delightful sdk cli, i\'am eva');
program
.command('init')
.description('init a sdk project')
.action(() => { init(); });
program
.command('lint')
.description('show eslint and style lint errors')
.action(() => {
checkDir();
lint();
});
program
.command('lint:fix')
.description('fix eslint and style lint errors')
.action(() => {
checkDir();
lint({ fix: true });
});
program
.command('dev')
.description('watch changes for development')
.action(() => {
checkDir();
dev();
});
program
.command('prod')
.description('deploy for production')
.action(() => {
checkDir();
prod();
});
program.on('command:*', () => {
console.log('');
console.log(
emoji.get('warning'),
chalk.yellow('Command not found, see usage:'),
);
console.log(program.helpInformation());
});
program.parse(process.argv);
const NO_COMMAND_SPECIFIED = program.args.length === 0;
if (NO_COMMAND_SPECIFIED) {
console.log(program.helpInformation());
}