1 | 'use strict';
|
2 | const { debugWrapper } = require('@midwayjs/debugger');
|
3 | const cliFun = async argv => {
|
4 | require('source-map-support/register');
|
5 | const { CLI, checkUpdate, findNpm } = require('../dist');
|
6 | if (!argv.npm) {
|
7 | argv.npm = findNpm(argv).cmd;
|
8 | }
|
9 |
|
10 | checkUpdate(argv.npm);
|
11 | const cli = new CLI(argv);
|
12 | cli
|
13 | .start()
|
14 | .then(() => {
|
15 | process.exit();
|
16 | })
|
17 | .catch(e => {
|
18 | console.log('\n\n\n');
|
19 | console.log(
|
20 | 'Error! You can try adding the -V parameter for more information output.'
|
21 | );
|
22 | console.log('\n\n\n');
|
23 | console.error(e);
|
24 | process.exitCode = 1;
|
25 | process.exit(1);
|
26 | });
|
27 | };
|
28 |
|
29 | const cli = argv => {
|
30 | const isDebug = argv.debug;
|
31 | delete argv.debug;
|
32 | debugWrapper({
|
33 | file: __filename,
|
34 | export: 'cliFun',
|
35 | debug: isDebug,
|
36 | })(argv);
|
37 | };
|
38 |
|
39 | module.exports = {
|
40 | cliFun,
|
41 | cli,
|
42 | };
|