@@ -183,7 +183,9 @@ export class ArduinoApp {
183
183
} )
184
184
. catch ( ( reason ) => {
185
185
this . _building = false ;
186
- // TODO EW, 2020-02-19: Report unhandled error (Logger?)
186
+ logger . notifyUserError ( "ArduinoApp.build" ,
187
+ reason ,
188
+ `Unhandled exception when cleaning up build (${ buildMode } ).` ) ;
187
189
return false ;
188
190
} ) ;
189
191
}
@@ -328,13 +330,6 @@ export class ArduinoApp {
328
330
arduinoChannel . show ( ) ;
329
331
arduinoChannel . start ( `${ buildMode } sketch '${ dc . sketch } '` ) ;
330
332
331
- // TODO EW: What should we do with pre-/post build commands when running
332
- // analysis? Some could use it to generate/manipulate code which could
333
- // be a prerequisite for a successful build
334
- if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
335
- return false ;
336
- }
337
-
338
333
if ( ( buildDir || dc . output ) && compile ) {
339
334
const outputPath = path . resolve ( ArduinoWorkspace . rootPath , buildDir || dc . output ) ;
340
335
const dirPath = path . dirname ( outputPath ) ;
@@ -356,6 +351,13 @@ export class ArduinoApp {
356
351
arduinoChannel . warning ( msg ) ;
357
352
}
358
353
354
+ // TODO EW: What should we do with pre-/post build commands when running
355
+ // analysis? Some could use it to generate/manipulate code which could
356
+ // be a prerequisite for a successful build
357
+ if ( ! await this . runPrePostBuildCommand ( dc , "pre" ) ) {
358
+ return false ;
359
+ }
360
+
359
361
// stop serial monitor when everything is prepared and good
360
362
// what makes restoring of its previous state easier
361
363
if ( buildMode === BuildMode . Upload || buildMode === BuildMode . UploadProgrammer ) {
@@ -365,10 +367,10 @@ export class ArduinoApp {
365
367
366
368
// Push sketch as last argument
367
369
args . push ( path . join ( ArduinoWorkspace . rootPath , dc . sketch ) ) ;
368
-
369
370
const cleanup = async ( result : "ok" | "error" ) => {
371
+ let ret = true ;
370
372
if ( result === "ok" ) {
371
- await this . runPrePostBuildCommand ( dc , "post" ) ;
373
+ ret = await this . runPrePostBuildCommand ( dc , "post" ) ;
372
374
}
373
375
await cocopa . conclude ( ) ;
374
376
if ( buildMode === BuildMode . Upload || buildMode === BuildMode . UploadProgrammer ) {
@@ -377,6 +379,7 @@ export class ArduinoApp {
377
379
await SerialMonitor . getInstance ( ) . openSerialMonitor ( ) ;
378
380
}
379
381
}
382
+ return ret ;
380
383
}
381
384
const stdoutcb = ( line : string ) => {
382
385
if ( cocopa . callback ) {
@@ -396,17 +399,13 @@ export class ArduinoApp {
396
399
line = `${ line } ${ os . EOL } ` ;
397
400
}
398
401
if ( ! verbose ) {
399
- // Don't spill log with spurious info from the backend
400
- // This list could be fetched from a config file to
401
- // accommodate messages of unknown board packages, newer
402
- // backend revisions etc.
402
+ // Don't spill log with spurious info from the backend. This
403
+ // list could be fetched from a config file to accommodate
404
+ // messages of unknown board packages, newer backend revisions
403
405
const filters = [
404
406
/ ^ P i c k e d \s u p \s J A V A _ T O O L _ O P T I O N S : \s + / ,
405
- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s I N F O \s / ,
406
- / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s W A R N \s / ,
407
- / ^ D E B U G \s + / ,
408
- / ^ T R A C E \s + / ,
409
- / ^ I N F O \s + / ,
407
+ / ^ \d + \d + - \d + - \d + T \d + : \d + : \d + .\d + Z \s (?: I N F O | W A R N ) \s / ,
408
+ / ^ (?: D E B U G | T R A C E | I N F O ) \s + / ,
410
409
] ;
411
410
for ( const f of filters ) {
412
411
if ( line . match ( f ) ) {
@@ -423,9 +422,11 @@ export class ArduinoApp {
423
422
undefined ,
424
423
{ stdout : stdoutcb , stderr : stderrcb } ,
425
424
) . then ( async ( ) => {
426
- await cleanup ( "ok" ) ;
427
- arduinoChannel . end ( `${ buildMode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
428
- return true ;
425
+ const ret = await cleanup ( "ok" ) ;
426
+ if ( ret ) {
427
+ arduinoChannel . end ( `${ buildMode } sketch '${ dc . sketch } '${ os . EOL } ` ) ;
428
+ }
429
+ return ret ;
429
430
} , async ( reason ) => {
430
431
await cleanup ( "error" ) ;
431
432
const msg = reason . code
0 commit comments