Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow the process to exit naturally #10400

Merged
merged 1 commit into from Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions packages/babel-cli/src/babel/index.js
Expand Up @@ -6,8 +6,12 @@ import fileCommand from "./file";

const opts = parseArgv(process.argv);

const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
fn(opts).catch(err => {
console.error(err);
process.exit(1);
});
if (opts) {
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
fn(opts).catch(err => {
console.error(err);
process.exitCode = 1;
});
} else {
process.exitCode = 2;
}
4 changes: 2 additions & 2 deletions packages/babel-cli/src/babel/options.js
Expand Up @@ -158,7 +158,7 @@ export type CmdOptions = {
cliOptions: Object,
};

export default function parseArgv(args: Array<string>): CmdOptions {
export default function parseArgv(args: Array<string>): CmdOptions | null {
//
commander.parse(args);

Expand Down Expand Up @@ -223,7 +223,7 @@ export default function parseArgv(args: Array<string>): CmdOptions {
errors.forEach(function(e) {
console.error(" " + e);
});
process.exit(2);
return null;
}

const opts = commander.opts();
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-cli/src/babel/util.js
Expand Up @@ -112,7 +112,7 @@ export function deleteDir(path: string): void {

process.on("uncaughtException", function(err) {
console.error(err);
process.exit(1);
process.exitCode = 1;
});

export function requireChokidar(): Object {
Expand Down