Skip to content

Commit 4ceed46

Browse files
mjesuncpojer
authored andcommitted
Fix recursive process.exit calls (#5445)
1 parent d743fec commit 4ceed46

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

packages/jest-cli/src/cli/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const readResultsAndExit = (
114114
) => {
115115
const code = !result || result.success ? 0 : globalConfig.testFailureExitCode;
116116

117-
process.on('exit', () => exit(code));
117+
process.on('exit', () => (process.exitCode = code));
118118

119119
if (globalConfig.forceExit) {
120120
exit(code);

packages/jest-runtime/src/cli/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {Argv} from 'types/Argv';
1111
import type {EnvironmentClass} from 'types/Environment';
1212

1313
import chalk from 'chalk';
14-
import exit from 'exit';
1514
import os from 'os';
1615
import path from 'path';
1716
import yargs from 'yargs';
@@ -43,7 +42,7 @@ export function run(cliArgv?: Argv, cliInfo?: Array<string>) {
4342

4443
if (argv.help) {
4544
yargs.showHelp();
46-
process.on('exit', () => exit(1));
45+
process.on('exit', () => (process.exitCode = 1));
4746
return;
4847
}
4948

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

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

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

0 commit comments

Comments
 (0)