-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
33 lines (28 loc) · 788 Bytes
/
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
#!/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');
const run = require('./lib/run');
// print version and @local
const args = yParser(process.argv.slice(2));
if (args.v || args.version) {
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 name = args._[0] || '';
const { type } = args;
delete args.type;
run({
name,
type,
args,
});