fix: allow the process to exit naturally (#10400)

This commit is contained in:
Huáng Jùnliàng 2019-09-11 06:24:44 -04:00 committed by Nicolò Ribaudo
parent af04f40ee0
commit 53af9e8b7a
3 changed files with 12 additions and 8 deletions

View File

@ -6,8 +6,12 @@ import fileCommand from "./file";
const opts = parseArgv(process.argv); const opts = parseArgv(process.argv);
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand; if (opts) {
fn(opts).catch(err => { const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
console.error(err); fn(opts).catch(err => {
process.exit(1); console.error(err);
}); process.exitCode = 1;
});
} else {
process.exitCode = 2;
}

View File

@ -158,7 +158,7 @@ export type CmdOptions = {
cliOptions: Object, cliOptions: Object,
}; };
export default function parseArgv(args: Array<string>): CmdOptions { export default function parseArgv(args: Array<string>): CmdOptions | null {
// //
commander.parse(args); commander.parse(args);
@ -223,7 +223,7 @@ export default function parseArgv(args: Array<string>): CmdOptions {
errors.forEach(function(e) { errors.forEach(function(e) {
console.error(" " + e); console.error(" " + e);
}); });
process.exit(2); return null;
} }
const opts = commander.opts(); const opts = commander.opts();

View File

@ -112,7 +112,7 @@ export function deleteDir(path: string): void {
process.on("uncaughtException", function(err) { process.on("uncaughtException", function(err) {
console.error(err); console.error(err);
process.exit(1); process.exitCode = 1;
}); });
export function requireChokidar(): Object { export function requireChokidar(): Object {