@@ -10,8 +10,7 @@ import { startLogging } from './start.js'
1010// `process.exit()` is being stubbed
1111export const startProcessLogging = function ( eventName , opts ) {
1212 const processHandler = setProcessEvent ( eventName )
13- stubProcessExit ( )
14- const { stopLogging } = startLogging ( opts )
13+ const stopLogging = startExitLogging ( opts )
1514 return stopProcessLogging . bind (
1615 undefined ,
1716 eventName ,
@@ -22,43 +21,31 @@ export const startProcessLogging = function (eventName, opts) {
2221
2322const stopProcessLogging = function ( eventName , stopLogging , processHandler ) {
2423 stopLogging ( )
25- unStubProcessExit ( )
2624 unsetProcessEvent ( eventName , processHandler )
2725}
2826
2927// Start logging while `setTimeout()` and `process.exit()` are being stubbed
3028export const startClockLogging = function ( opts ) {
3129 const clock = fakeTimers . install ( { toFake : [ 'setTimeout' ] } )
32- stubProcessExit ( )
33- const { stopLogging } = startLogging ( opts )
30+ const stopLogging = startExitLogging ( opts )
3431 const stopLoggingA = stopClockLogging . bind ( undefined , stopLogging , clock )
3532 return { clock, stopLogging : stopLoggingA }
3633}
3734
3835const stopClockLogging = function ( stopLogging , clock ) {
3936 stopLogging ( )
40- unStubProcessExit ( )
4137 clock . uninstall ( )
4238}
4339
4440// Start logging while `process.exit()` is being stubbed
4541export const startExitLogging = function ( opts ) {
46- stubProcessExit ( )
42+ sinon . stub ( process , 'exit' )
4743 const { stopLogging } = startLogging ( opts )
4844 return stopExitLogging . bind ( undefined , stopLogging )
4945}
5046
5147const stopExitLogging = function ( stopLogging ) {
5248 stopLogging ( )
53- unStubProcessExit ( )
54- }
55-
56- // Stub `process.exit()`
57- const stubProcessExit = function ( ) {
58- sinon . stub ( process , 'exit' )
59- }
60-
61- const unStubProcessExit = function ( ) {
6249 process . exit . restore ( )
6350 process . exitCode = undefined
6451}
0 commit comments