-
Notifications
You must be signed in to change notification settings - Fork 102
/
cli.js
50 lines (42 loc) · 1.2 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
50
#!/usr/bin/env node
const yParser = require('yargs-parser');
const semver = require('semver');
const { existsSync } = require('fs');
const { join } = require('path');
const chalk = require('chalk');
// print version and @local
const args = yParser(process.argv.slice(2));
if (args.v || args.version) {
// eslint-disable-next-line global-require
console.log(require('./package').version);
if (existsSync(join(__dirname, '.local'))) {
console.log(chalk.cyan('@local'));
}
process.exit(0);
}
if (!semver.satisfies(process.version, '>= 8.0.0')) {
console.error(chalk.red('✘ The generator will only work with Node v8.0.0 and up!'));
process.exit(1);
}
const cwd = process.cwd();
const option = args._[0];
switch (option) {
case 'verify-commit':
// eslint-disable-next-line global-require
require('./dist/verifyCommit');
break;
default:
if (args.h || args.help) {
const details = `
Commands:
${chalk.cyan('verify-commit')} 检查 commit 提交的信息
Examples:
${chalk.gray('fabric')}
fabric -h
${chalk.gray('verify-commit ')}
fabric verify-commit
`.trim();
console.log(details);
}
break;
}