-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·31 lines (30 loc) · 884 Bytes
/
cli.js
File metadata and controls
executable file
·31 lines (30 loc) · 884 Bytes
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
#!/usr/bin/env node
const execa = require('execa');
const package = require('./package.json');
const path = require('path');
const binPath = path.resolve(__dirname, './node_modules/.bin/');
const getBinPath = (name) => {
return path.resolve(binPath, name);
};
const exec = (file, args, options) => {
return execa(file, args, {
stdout: process.stdout,
stderr: process.stderr,
...options,
});
};
const yargs = require('yargs');
yargs
.commandDir('build/commands')
// 代码补全
.completion('completion', function(current, argv) {
// 'current' is the current command being completed.
// 'argv' is the parsed arguments so far.
// simply return an array of completions.
return ['generate-migrate', 'run-migrate'];
})
.demandCommand()
.help('help')
.alias('help', 'h')
.version('version', package.version)
.alias('version', 'v').argv;