@@ -23,7 +23,6 @@ import { helper } from './helper';
23
23
import { Progress } from './progress' ;
24
24
import * as types from './types' ;
25
25
import { isUnderTest } from '../utils/utils' ;
26
- import { EventEmitter } from 'events' ;
27
26
28
27
export type Env = { [ key : string ] : string | number | boolean | undefined } ;
29
28
@@ -59,26 +58,6 @@ export async function gracefullyCloseAll() {
59
58
await Promise . all ( Array . from ( gracefullyCloseSet ) . map ( gracefullyClose => gracefullyClose ( ) . catch ( e => { } ) ) ) ;
60
59
}
61
60
62
- class EventEmitterWrapper extends EventEmitter {
63
- private _wrappedEvents : Set < string | symbol > ;
64
- constructor ( emitter : EventEmitter ) {
65
- super ( ) ;
66
- this . setMaxListeners ( 0 ) ;
67
- this . _wrappedEvents = new Set ( ) ;
68
- for ( const method of [ 'addListener' , 'on' , 'once' , 'prependListener' , 'prependOnceListener' ] as const ) {
69
- this [ method ] = ( event : string | symbol , listener : ( ...args : any [ ] ) => void ) => {
70
- if ( ! this . _wrappedEvents . has ( event ) ) {
71
- this . _wrappedEvents . add ( event ) ;
72
- emitter . addListener ( event , ( ...eventArgs ) => this . emit ( event , ...eventArgs ) ) ;
73
- }
74
- return super [ method ] ( event , listener ) ;
75
- } ;
76
- }
77
- }
78
- }
79
-
80
- const processWrapper = new EventEmitterWrapper ( process ) ;
81
-
82
61
export async function launchProcess ( options : LaunchProcessOptions ) : Promise < LaunchResult > {
83
62
const cleanup = ( ) => helper . removeFolders ( options . tempDirectories ) ;
84
63
@@ -136,9 +115,9 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
136
115
cleanup ( ) . then ( fulfillCleanup ) ;
137
116
} ) ;
138
117
139
- const listeners = [ helper . addEventListener ( processWrapper , 'exit' , killProcess ) ] ;
118
+ const listeners = [ helper . addEventListener ( process , 'exit' , killProcess ) ] ;
140
119
if ( options . handleSIGINT ) {
141
- listeners . push ( helper . addEventListener ( processWrapper , 'SIGINT' , ( ) => {
120
+ listeners . push ( helper . addEventListener ( process , 'SIGINT' , ( ) => {
142
121
gracefullyClose ( ) . then ( ( ) => {
143
122
// Give tests a chance to dispatch any async calls.
144
123
if ( isUnderTest ( ) )
@@ -149,9 +128,9 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun
149
128
} ) ) ;
150
129
}
151
130
if ( options . handleSIGTERM )
152
- listeners . push ( helper . addEventListener ( processWrapper , 'SIGTERM' , gracefullyClose ) ) ;
131
+ listeners . push ( helper . addEventListener ( process , 'SIGTERM' , gracefullyClose ) ) ;
153
132
if ( options . handleSIGHUP )
154
- listeners . push ( helper . addEventListener ( processWrapper , 'SIGHUP' , gracefullyClose ) ) ;
133
+ listeners . push ( helper . addEventListener ( process , 'SIGHUP' , gracefullyClose ) ) ;
155
134
gracefullyCloseSet . add ( gracefullyClose ) ;
156
135
157
136
let gracefullyClosing = false ;
0 commit comments