File tree 2 files changed +9
-9
lines changed
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 8
8
*/
9
9
'use strict' ;
10
10
11
- const { launchEditor } = require ( './launchEditor' ) ;
11
+ const { launchEditor, tryLaunchPowerShellAgent } = require ( './launchEditor' ) ;
12
12
const launchEditorEndpoint = require ( './launchEditorEndpoint' ) ;
13
13
14
14
module . exports = function createLaunchEditorMiddleware ( ) {
15
15
if ( process . platform === 'win32' && ! process . env . REACT_EDITOR ) {
16
- const {
17
- tryLaunchPowerShellAgent,
18
- } = require ( 'react-dev-utils/launchEditor' ) ;
19
16
tryLaunchPowerShellAgent ( ) ;
20
17
}
21
18
Original file line number Diff line number Diff line change @@ -38,10 +38,15 @@ class PowerShell extends EventEmitter {
38
38
throw new Error ( 'Failed to start PowerShell' ) ;
39
39
}
40
40
41
+ // Initialize counters for mapping events
42
+ this . _callbackCounter = 0 ;
43
+ this . _resolveCounter = 0 ;
44
+
41
45
let output = [ ] ;
42
46
this . _proc . stdout . on ( 'data' , data => {
43
47
if ( data . indexOf ( EOI ) !== - 1 ) {
44
- this . emit ( 'resolve' , output . join ( '' ) ) ;
48
+ const eventName = 'resolve' + ++ this . _callbackCounter ;
49
+ this . emit ( eventName , output . join ( '' ) ) ;
45
50
output = [ ] ;
46
51
} else {
47
52
output . push ( data ) ;
@@ -51,10 +56,8 @@ class PowerShell extends EventEmitter {
51
56
52
57
invoke ( cmd ) {
53
58
return new Promise ( resolve => {
54
- this . on ( 'resolve' , data => {
55
- resolve ( data ) ;
56
- this . removeAllListeners ( 'resolve' ) ;
57
- } ) ;
59
+ const eventName = 'resolve' + ++ this . _resolveCounter ;
60
+ this . once ( eventName , resolve ) ;
58
61
59
62
this . _proc . stdin . write ( cmd ) ;
60
63
this . _proc . stdin . write ( os . EOL ) ;
You can’t perform that action at this time.
0 commit comments