@@ -244,9 +244,9 @@ Please make sure the folder is not occupied by other procedures .`);
244
244
}
245
245
try {
246
246
await util . spawn ( this . _settings . commandPath ,
247
- showOutput ? arduinoChannel . channel : null ,
248
- [ "--install-boards" , ` ${ packageName } ${ arch && ":" + arch } ${ version && ":" + version } ` ] ) ;
249
-
247
+ [ "--install-boards" , ` ${ packageName } ${ arch && ":" + arch } ${ version && ":" + version } ` ] ,
248
+ undefined ,
249
+ { channel : showOutput ? arduinoChannel . channel : null } ) ;
250
250
if ( updatingIndex ) {
251
251
arduinoChannel . end ( "Updated package index files." ) ;
252
252
} else {
@@ -282,9 +282,9 @@ Please make sure the folder is not occupied by other procedures .`);
282
282
}
283
283
try {
284
284
await util . spawn ( this . _settings . commandPath ,
285
- showOutput ? arduinoChannel . channel : null ,
286
- [ "--install-library" , ` ${ libName } ${ version && ":" + version } ` ] ) ;
287
-
285
+ [ "--install-library" , ` ${ libName } ${ version && ":" + version } ` ] ,
286
+ undefined ,
287
+ { channel : showOutput ? arduinoChannel . channel : undefined } ) ;
288
288
if ( updatingIndex ) {
289
289
arduinoChannel . end ( "Updated library index files." ) ;
290
290
} else {
@@ -418,9 +418,9 @@ Please make sure the folder is not occupied by other procedures .`);
418
418
const cmd = args . shift ( ) ;
419
419
try {
420
420
await util . spawn ( cmd ,
421
- arduinoChannel . channel ,
422
421
args ,
423
- { shell : true , cwd : ArduinoWorkspace . rootPath } ) ;
422
+ { shell : true , cwd : ArduinoWorkspace . rootPath } ,
423
+ { channel : arduinoChannel . channel } ) ;
424
424
} catch ( ex ) {
425
425
arduinoChannel . error ( `Running pre-build command failed: ${ os . EOL } ${ ex . error } ` ) ;
426
426
return false ;
@@ -548,8 +548,6 @@ Please make sure the folder is not occupied by other procedures .`);
548
548
// Push sketch as last argument
549
549
args . push ( path . join ( ArduinoWorkspace . rootPath , dc . sketch ) ) ;
550
550
551
- let success = false ;
552
-
553
551
const cleanup = async ( ) => {
554
552
if ( cocopa ) {
555
553
await cocopa . conclude ( ) ;
@@ -562,25 +560,14 @@ Please make sure the folder is not occupied by other procedures .`);
562
560
}
563
561
}
564
562
565
- // TODO: Get rid of spawn's channel parameter and just support
566
- // stdout and stderr callbacks
567
- const stdoutCallback = ( line : string ) => {
568
- if ( cocopa ) {
569
- cocopa . callback ( line ) ;
570
- if ( verbose ) {
571
- arduinoChannel . channel . append ( line ) ;
572
- }
573
- } else {
574
- arduinoChannel . channel . append ( line ) ;
575
- }
576
- }
577
-
578
- await util . spawn (
563
+ return await util . spawn (
579
564
this . _settings . commandPath ,
580
- arduinoChannel . channel ,
581
565
args ,
582
566
undefined ,
583
- stdoutCallback ,
567
+ {
568
+ channel : ! cocopa || cocopa && verbose ? arduinoChannel . channel : undefined ,
569
+ stdout : cocopa ? cocopa . callback : undefined ,
570
+ }
584
571
) . then ( async ( ) => {
585
572
await cleanup ( ) ;
586
573
if ( mode !== BuildMode . Analyze ) {
@@ -590,17 +577,14 @@ Please make sure the folder is not occupied by other procedures .`);
590
577
arduinoChannel . info ( `To rebuild your IntelliSense configuration run "${ cmd } "` ) ;
591
578
}
592
579
arduinoChannel . end ( `${ mode } sketch '${ dc . sketch } ${ os . EOL } ` ) ;
593
- success = true ;
580
+ return true ;
594
581
} , async ( reason ) => {
595
582
await cleanup ( ) ;
596
583
const msg = reason . code
597
584
? `Exit with code=${ reason . code } `
598
- : reason . message
599
- ? reason . message
600
- : JSON . stringify ( reason ) ;
585
+ : JSON . stringify ( reason ) ;
601
586
arduinoChannel . error ( `${ mode } sketch '${ dc . sketch } ': ${ msg } ${ os . EOL } ` ) ;
587
+ return false ;
602
588
} ) ;
603
-
604
- return success ;
605
589
}
606
590
}
0 commit comments