@@ -329,47 +329,58 @@ export const buildCommand: yargs.CommandModule<
329329 }
330330 } ) ;
331331
332- const results = await Promise . allSettled ( tasks ) ;
333-
334- const failedSandboxes = templateData . sandboxes . filter (
335- ( _ , index ) => results [ index ] . status === "rejected"
336- ) ;
337-
338- if ( ! argv . ci && failedSandboxes . length > 0 ) {
339- spinner . start ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
332+ if ( argv . ci ) {
333+ try {
334+ await Promise . all ( tasks ) ;
335+ } catch {
336+ spinner . fail ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
337+ process . exit ( 1 ) ;
338+ }
339+ } else {
340+ const results = await Promise . allSettled ( tasks ) ;
340341
341- await waitForEnter (
342- `\nThere was an issue preparing the sandboxes. Verify ${ failedSandboxes
343- . map ( ( sandbox ) => sandbox . id )
344- . join ( ", " ) } and press ENTER to create snapshot...\n`
342+ const failedSandboxes = templateData . sandboxes . filter (
343+ ( _ , index ) => results [ index ] . status === "rejected"
345344 ) ;
346345
347- failedSandboxes . forEach ( ( { id } ) => {
348- updateSpinnerMessage (
349- templateData . sandboxes . findIndex ( ( sandbox ) => sandbox . id === id ) ,
350- "Creating snapshot..."
346+ if ( failedSandboxes . length > 0 ) {
347+ spinner . start (
348+ `\n${ spinnerMessages . join (
349+ "\n"
350+ ) } \n\nThere was an issue preparing the sandboxes. Verify ${ failedSandboxes
351+ . map ( ( sandbox ) => sandbox . id )
352+ . join ( ", " ) } and press ENTER to create snapshot...\n`
351353 ) ;
352- } ) ;
353354
354- spinner . start ( `\n ${ spinnerMessages . join ( "\n" ) } ` ) ;
355+ await waitForEnter ( ) ;
355356
356- await Promise . all (
357- failedSandboxes . map ( async ( { id } ) => {
358- await sdk . sandboxes . hibernate ( id ) ;
359-
360- spinner . start (
361- updateSpinnerMessage (
362- templateData . sandboxes . findIndex (
363- ( sandbox ) => sandbox . id === id
364- ) ,
365- "Snapshot created"
366- )
357+ failedSandboxes . forEach ( ( { id } ) => {
358+ updateSpinnerMessage (
359+ templateData . sandboxes . findIndex ( ( sandbox ) => sandbox . id === id ) ,
360+ "Creating snapshot..."
367361 ) ;
368- } )
369- ) ;
370- spinner . succeed ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
371- } else {
372- spinner . succeed ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
362+ } ) ;
363+
364+ spinner . start ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
365+
366+ await Promise . all (
367+ failedSandboxes . map ( async ( { id } ) => {
368+ await sdk . sandboxes . hibernate ( id ) ;
369+
370+ spinner . start (
371+ updateSpinnerMessage (
372+ templateData . sandboxes . findIndex (
373+ ( sandbox ) => sandbox . id === id
374+ ) ,
375+ "Snapshot created"
376+ )
377+ ) ;
378+ } )
379+ ) ;
380+ spinner . succeed ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
381+ } else {
382+ spinner . succeed ( `\n${ spinnerMessages . join ( "\n" ) } ` ) ;
383+ }
373384 }
374385
375386 if ( alias ) {
@@ -392,10 +403,6 @@ export const buildCommand: yargs.CommandModule<
392403
393404 console . log ( "Template created: " + templateData . tag ) ;
394405
395- if ( argv . ci && failedSandboxes . length > 0 ) {
396- process . exit ( 1 ) ;
397- }
398-
399406 process . exit ( 0 ) ;
400407 } catch ( error ) {
401408 console . error ( error ) ;
@@ -410,14 +417,14 @@ function withCustomError<T extends Promise<any>>(promise: T, message: string) {
410417 } ) ;
411418}
412419
413- function waitForEnter ( message : string ) {
420+ function waitForEnter ( ) {
414421 const rl = readline . createInterface ( {
415422 input : process . stdin ,
416423 output : process . stdout ,
417424 } ) ;
418425
419426 return new Promise < void > ( ( resolve ) => {
420- rl . question ( message , ( ) => {
427+ rl . question ( "" , ( ) => {
421428 rl . close ( ) ;
422429 resolve ( ) ;
423430 } ) ;
0 commit comments