From 4ceed46b4e9dcfe5a9b1944bc8a7f5a4d4ccbb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Jim=C3=A9nez=20Es=C3=BAn?= Date: Fri, 2 Feb 2018 21:53:18 +0100 Subject: [PATCH] Fix recursive process.exit calls (#5445) --- packages/jest-cli/src/cli/index.js | 2 +- packages/jest-runtime/src/cli/index.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index f498d63c166c..42d39276331e 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -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); diff --git a/packages/jest-runtime/src/cli/index.js b/packages/jest-runtime/src/cli/index.js index 3c785116cd08..a936d5879b14 100644 --- a/packages/jest-runtime/src/cli/index.js +++ b/packages/jest-runtime/src/cli/index.js @@ -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'; @@ -43,7 +42,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { if (argv.help) { yargs.showHelp(); - process.on('exit', () => exit(1)); + process.on('exit', () => (process.exitCode = 1)); return; } @@ -54,7 +53,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { 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; } @@ -93,6 +92,6 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { }) .catch(e => { console.error(chalk.red(e.stack || e)); - process.on('exit', () => exit(1)); + process.on('exit', () => (process.exitCode = 1)); }); }