Skip to content

Commit

Permalink
Fix recursive process.exit calls (#5445)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjesun authored and cpojer committed Feb 2, 2018
1 parent d743fec commit 4ceed46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const readResultsAndExit = (
) => {
const code = !result || result.success ? 0 : globalConfig.testFailureExitCode;

process.on('exit', () => exit(code));
process.on('exit', () => (process.exitCode = code));

if (globalConfig.forceExit) {
exit(code);
Expand Down
7 changes: 3 additions & 4 deletions packages/jest-runtime/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {Argv} from 'types/Argv';
import type {EnvironmentClass} from 'types/Environment';

import chalk from 'chalk';
import exit from 'exit';
import os from 'os';
import path from 'path';
import yargs from 'yargs';
Expand Down Expand Up @@ -43,7 +42,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {

if (argv.help) {
yargs.showHelp();
process.on('exit', () => exit(1));
process.on('exit', () => (process.exitCode = 1));
return;
}

Expand All @@ -54,7 +53,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {

if (!argv._.length) {
console.log('Please provide a path to a script. (See --help for details)');
process.on('exit', () => exit(1));
process.on('exit', () => (process.exitCode = 1));
return;
}

Expand Down Expand Up @@ -93,6 +92,6 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {
})
.catch(e => {
console.error(chalk.red(e.stack || e));
process.on('exit', () => exit(1));
process.on('exit', () => (process.exitCode = 1));
});
}

0 comments on commit 4ceed46

Please sign in to comment.