@@ -28,14 +28,16 @@ function releaseBuild() {
28
28
* lock files shouldn't rely on the umask to disallow tampering by other.
29
29
*
30
30
* @param {Array<string> } args
31
+ * @param {child_process.SpawnOptions } [options]
31
32
*/
32
- function acquireBuild ( args ) {
33
+ function acquireBuild ( args , options ) {
33
34
if ( ownerProcess ) {
34
35
return null ;
35
36
} else {
36
37
try {
37
38
ownerProcess = child_process . spawn ( rescript_exe , args , {
38
39
stdio : "inherit" ,
40
+ ...options ,
39
41
} ) ;
40
42
fs . writeFileSync ( lockFileName , ownerProcess . pid . toString ( ) , {
41
43
encoding : "utf8" ,
@@ -370,17 +372,17 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
370
372
} else {
371
373
dlog ( `Rebuilding since ${ reasonsToRebuild } ` ) ;
372
374
}
373
- if ( acquireBuild ( args ) ) {
375
+ let p ;
376
+ if (
377
+ ( p = acquireBuild ( rescriptWatchBuildArgs , {
378
+ stdio : [ "inherit" , "inherit" , "pipe" ] ,
379
+ } ) )
380
+ ) {
374
381
logStartCompiling ( ) ;
375
- child_process
376
- . spawn ( rescript_exe , rescriptWatchBuildArgs , {
377
- stdio : [ "inherit" , "inherit" , "pipe" ] ,
378
- } )
379
- // @ts -ignore
380
- . on ( "data" , function ( s ) {
381
- outputError ( s , "ninja: error" ) ;
382
- } )
383
- . on ( "exit" , buildFinishedCallback )
382
+ p . on ( "data" , function ( s ) {
383
+ outputError ( s , "ninja: error" ) ;
384
+ } )
385
+ . once ( "exit" , buildFinishedCallback )
384
386
. stderr . setEncoding ( "utf8" ) ;
385
387
// This is important to clean up all
386
388
// previous queued events
0 commit comments