@@ -22,6 +22,7 @@ import {version as VERSION} from '../../package.json';
2222import * as args from './args' ;
2323import chalk from 'chalk' ;
2424import createContext from '../lib/create_context' ;
25+ import exit from 'exit' ;
2526import getChangedFilesPromise from '../get_changed_files_promise' ;
2627import handleDeprecationWarnings from '../lib/handle_deprecation_warnings' ;
2728import logDebugMessages from '../lib/log_debug_messages' ;
@@ -45,7 +46,7 @@ export async function run(maybeArgv?: Argv, project?: Path) {
4546 clearLine ( process . stderr ) ;
4647 clearLine ( process . stdout ) ;
4748 console . error ( chalk . red ( error . stack ) ) ;
48- process . exit ( 1 ) ;
49+ exit ( 1 ) ;
4950 throw error ;
5051 }
5152}
@@ -79,7 +80,7 @@ export const runCLI = async (
7980 process . stdout . write ( `Cleared ${ config . cacheDirectory } \n` ) ;
8081 } ) ;
8182
82- process . exit ( 0 ) ;
83+ exit ( 0 ) ;
8384 }
8485
8586 await _run (
@@ -111,9 +112,11 @@ const readResultsAndExit = (
111112 globalConfig : GlobalConfig ,
112113) = > {
113114 const code = ! result || result . success ? 0 : globalConfig . testFailureExitCode ;
114- process . on ( 'exit' , ( ) => process . exit ( code ) ) ;
115+
116+ process . on ( 'exit' , ( ) => exit ( code ) ) ;
117+
115118 if ( globalConfig . forceExit ) {
116- process . exit ( code ) ;
119+ exit ( code ) ;
117120 }
118121} ;
119122
@@ -164,13 +167,13 @@ const printDebugInfoAndExitIfNeeded = (
164167 logDebugMessages ( globalConfig , configs , outputStream ) ;
165168 }
166169 if ( argv . showConfig ) {
167- process . exit ( 0 ) ;
170+ exit ( 0 ) ;
168171 }
169172} ;
170173
171174const printVersionAndExit = outputStream => {
172175 outputStream . write ( `v${ VERSION } \n` ) ;
173- process . exit ( 0 ) ;
176+ exit ( 0 ) ;
174177} ;
175178
176179const ensureNoDuplicateConfigs = ( parsedConfigs , projects ) => {
@@ -346,7 +349,7 @@ const runWatch = async (
346349 await handleDeprecationWarnings ( outputStream , process . stdin ) ;
347350 return watch ( globalConfig , contexts , outputStream , hasteMapInstances ) ;
348351 } catch ( e ) {
349- process . exit ( 0 ) ;
352+ exit ( 0 ) ;
350353 }
351354 }
352355
0 commit comments