fix: allow the process to exit naturally (#10400)
This commit is contained in:
parent
af04f40ee0
commit
53af9e8b7a
@ -6,8 +6,12 @@ import fileCommand from "./file";
|
|||||||
|
|
||||||
const opts = parseArgv(process.argv);
|
const opts = parseArgv(process.argv);
|
||||||
|
|
||||||
|
if (opts) {
|
||||||
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
|
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
|
||||||
fn(opts).catch(err => {
|
fn(opts).catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
process.exit(1);
|
process.exitCode = 1;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
process.exitCode = 2;
|
||||||
|
}
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user