2
2
const { spawn } = require ( "child_process" ) ;
3
3
const { normalize } = require ( "path" ) ;
4
4
5
- const termiateSignals = [ "close" , "exit" , "" ] ;
5
+ // 'disconnect' is not needed as it will only be raised, when either the child process or this process calss disconnect explicitly.
6
+ // We are abel to ensure, that this will never happen, as we do not need communication with the spawned subprocess
7
+ const terminationSignal = [ "close" , "exit" ] ;
6
8
7
9
function startSubprocess ( ) {
8
10
return new Promise ( ( res , rej ) => {
9
- const proc = spawn ( process . argv . slice ( 2 ) . map ( normalize ) . join ( " " ) , {
11
+ const [ command , ...args ] = process . argv . slice ( 2 ) ;
12
+ const proc = spawn ( normalize ( command ) , args , {
10
13
stdio : [ "pipe" , "pipe" , "pipe" ] ,
11
14
shell :
12
15
process . platform === "win32" ||
@@ -15,7 +18,7 @@ function startSubprocess() {
15
18
proc . stdout . pipe ( process . stdout ) ;
16
19
proc . stderr . pipe ( process . stderr ) ;
17
20
process . stdin . pipe ( proc . stdin ) ;
18
- termiateSignals . forEach ( ( e ) => proc . on ( e , res ) ) ;
21
+ terminationSignal . forEach ( ( event ) => proc . on ( event , res ) ) ;
19
22
proc . on ( "error" , rej ) ;
20
23
} ) ;
21
24
}
0 commit comments