File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 88 */
99'use strict' ;
1010
11- const { launchEditor } = require ( './launchEditor' ) ;
11+ const { launchEditor, tryLaunchPowerShellAgent } = require ( './launchEditor' ) ;
1212const launchEditorEndpoint = require ( './launchEditorEndpoint' ) ;
1313
1414module . exports = function createLaunchEditorMiddleware ( ) {
1515 if ( process . platform === 'win32' && ! process . env . REACT_EDITOR ) {
16- const {
17- tryLaunchPowerShellAgent,
18- } = require ( 'react-dev-utils/launchEditor' ) ;
1916 tryLaunchPowerShellAgent ( ) ;
2017 }
2118
Original file line number Diff line number Diff line change @@ -38,10 +38,15 @@ class PowerShell extends EventEmitter {
3838 throw new Error ( 'Failed to start PowerShell' ) ;
3939 }
4040
41+ // Initialize counters for mapping events
42+ this . _callbackCounter = 0 ;
43+ this . _resolveCounter = 0 ;
44+
4145 let output = [ ] ;
4246 this . _proc . stdout . on ( 'data' , data => {
4347 if ( data . indexOf ( EOI ) !== - 1 ) {
44- this . emit ( 'resolve' , output . join ( '' ) ) ;
48+ const eventName = 'resolve' + ++ this . _callbackCounter ;
49+ this . emit ( eventName , output . join ( '' ) ) ;
4550 output = [ ] ;
4651 } else {
4752 output . push ( data ) ;
@@ -51,10 +56,8 @@ class PowerShell extends EventEmitter {
5156
5257 invoke ( cmd ) {
5358 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 ) ;
5861
5962 this . _proc . stdin . write ( cmd ) ;
6063 this . _proc . stdin . write ( os . EOL ) ;
You can’t perform that action at this time.
0 commit comments