@@ -484,22 +484,22 @@ async function runLifecycleCommand({ lifecycleHook }: ResolverParameters, contai
484
484
} ,
485
485
onDidChangeDimensions : lifecycleHook . output . onDidChangeDimensions ,
486
486
} , LogLevel . Info ) ;
487
- try {
488
- const remoteCwd = containerProperties . remoteWorkspaceFolder || containerProperties . homeFolder ;
489
- async function runSingleCommand ( postCommand : string | string [ ] , name ?: string ) {
490
- const progressDetail = typeof postCommand === 'string' ? postCommand : postCommand . join ( ' ' ) ;
491
- infoOutput . event ( {
492
- type : 'progress' ,
493
- name : progressName ,
494
- status : 'running' ,
495
- stepDetail : progressDetail
496
- } ) ;
487
+ const remoteCwd = containerProperties . remoteWorkspaceFolder || containerProperties . homeFolder ;
488
+ async function runSingleCommand ( postCommand : string | string [ ] , name ?: string ) {
489
+ const progressDetail = typeof postCommand === 'string' ? postCommand : postCommand . join ( ' ' ) ;
490
+ infoOutput . event ( {
491
+ type : 'progress' ,
492
+ name : progressName ,
493
+ status : 'running' ,
494
+ stepDetail : progressDetail
495
+ } ) ;
497
496
498
- // If we have a command name then the command is running in parallel and
499
- // we need to hold output until the command is done so that the output
500
- // doesn't get interleaved with the output of other commands.
501
- const printMode = name ? 'off' : 'continuous' ;
502
- const env = { ...( await remoteEnv ) , ...( await secrets ) } ;
497
+ // If we have a command name then the command is running in parallel and
498
+ // we need to hold output until the command is done so that the output
499
+ // doesn't get interleaved with the output of other commands.
500
+ const printMode = name ? 'off' : 'continuous' ;
501
+ const env = { ...( await remoteEnv ) , ...( await secrets ) } ;
502
+ try {
503
503
const { cmdOutput } = await runRemoteCommand ( { ...lifecycleHook , output : infoOutput } , containerProperties , typeof postCommand === 'string' ? [ '/bin/sh' , '-c' , postCommand ] : postCommand , remoteCwd , { remoteEnv : env , pty : true , print : printMode } ) ;
504
504
505
505
// 'name' is set when parallel execution syntax is used.
@@ -512,38 +512,41 @@ async function runLifecycleCommand({ lifecycleHook }: ResolverParameters, contai
512
512
name : progressName ,
513
513
status : 'succeeded' ,
514
514
} ) ;
515
+ } catch ( err ) {
516
+ infoOutput . event ( {
517
+ type : 'progress' ,
518
+ name : progressName ,
519
+ status : 'failed' ,
520
+ } ) ;
521
+ if ( err ?. cmdOutput ) {
522
+ infoOutput . raw ( `\r\n\x1b[1m${ err . cmdOutput } \x1b[0m\r\n\r\n` ) ;
523
+ }
524
+ if ( err && ( err . code === 130 || err . signal === 2 ) ) { // SIGINT seen on darwin as code === 130, would also make sense as signal === 2.
525
+ infoOutput . raw ( `\r\n\x1b[1m${ lifecycleHookName } interrupted.\x1b[0m\r\n\r\n` ) ;
526
+ } else {
527
+ if ( err ?. code ) {
528
+ infoOutput . write ( toErrorText ( `${ lifecycleHookName } failed with exit code ${ err . code } . Skipping any further user-provided commands.` ) ) ;
529
+ }
530
+ throw new ContainerError ( {
531
+ description : `The ${ lifecycleHookName } in the ${ userCommandOrigin } failed.` ,
532
+ originalError : err
533
+ } ) ;
534
+ }
515
535
}
536
+ }
516
537
517
- infoOutput . raw ( `\x1b[1mRunning the ${ lifecycleHookName } from ${ userCommandOrigin } ...\x1b[0m\r\n\r\n` ) ;
538
+ infoOutput . raw ( `\x1b[1mRunning the ${ lifecycleHookName } from ${ userCommandOrigin } ...\x1b[0m\r\n\r\n` ) ;
518
539
519
- let commands ;
520
- if ( typeof userCommand === 'string' || Array . isArray ( userCommand ) ) {
521
- commands = [ runSingleCommand ( userCommand ) ] ;
522
- } else {
523
- commands = Object . keys ( userCommand ) . map ( name => {
524
- const command = userCommand [ name ] ;
525
- return runSingleCommand ( command , name ) ;
526
- } ) ;
527
- }
528
- await Promise . all ( commands ) ;
529
- } catch ( err ) {
530
- infoOutput . event ( {
531
- type : 'progress' ,
532
- name : progressName ,
533
- status : 'failed' ,
540
+ let commands ;
541
+ if ( typeof userCommand === 'string' || Array . isArray ( userCommand ) ) {
542
+ commands = [ runSingleCommand ( userCommand ) ] ;
543
+ } else {
544
+ commands = Object . keys ( userCommand ) . map ( name => {
545
+ const command = userCommand [ name ] ;
546
+ return runSingleCommand ( command , name ) ;
534
547
} ) ;
535
- if ( err && ( err . code === 130 || err . signal === 2 ) ) { // SIGINT seen on darwin as code === 130, would also make sense as signal === 2.
536
- infoOutput . raw ( `\r\n\x1b[1m${ lifecycleHookName } interrupted.\x1b[0m\r\n\r\n` ) ;
537
- } else {
538
- if ( err ?. code ) {
539
- infoOutput . write ( toErrorText ( `${ lifecycleHookName } failed with exit code ${ err . code } . Skipping any further user-provided commands.` ) ) ;
540
- }
541
- throw new ContainerError ( {
542
- description : `The ${ lifecycleHookName } in the ${ userCommandOrigin } failed.` ,
543
- originalError : err
544
- } ) ;
545
- }
546
548
}
549
+ await Promise . all ( commands ) ;
547
550
}
548
551
}
549
552
@@ -641,7 +644,7 @@ export async function runRemoteCommand(params: { output: Log; onDidInput?: Event
641
644
}
642
645
if ( exit . code || exit . signal ) {
643
646
return Promise . reject ( {
644
- message : `Command failed: ${ cmd . join ( ' ' ) } \r\n\r\n ${ cmdOutput } ` ,
647
+ message : `Command failed: ${ cmd . join ( ' ' ) } ` ,
645
648
cmdOutput,
646
649
code : exit . code ,
647
650
signal : exit . signal ,
0 commit comments