@@ -329,47 +329,58 @@ export const buildCommand: yargs.CommandModule<
329
329
}
330
330
} ) ;
331
331
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 ) ;
340
341
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"
345
344
) ;
346
345
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`
351
353
) ;
352
- } ) ;
353
354
354
- spinner . start ( `\n ${ spinnerMessages . join ( "\n" ) } ` ) ;
355
+ await waitForEnter ( ) ;
355
356
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..."
367
361
) ;
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
+ }
373
384
}
374
385
375
386
if ( alias ) {
@@ -392,10 +403,6 @@ export const buildCommand: yargs.CommandModule<
392
403
393
404
console . log ( "Template created: " + templateData . tag ) ;
394
405
395
- if ( argv . ci && failedSandboxes . length > 0 ) {
396
- process . exit ( 1 ) ;
397
- }
398
-
399
406
process . exit ( 0 ) ;
400
407
} catch ( error ) {
401
408
console . error ( error ) ;
@@ -410,14 +417,14 @@ function withCustomError<T extends Promise<any>>(promise: T, message: string) {
410
417
} ) ;
411
418
}
412
419
413
- function waitForEnter ( message : string ) {
420
+ function waitForEnter ( ) {
414
421
const rl = readline . createInterface ( {
415
422
input : process . stdin ,
416
423
output : process . stdout ,
417
424
} ) ;
418
425
419
426
return new Promise < void > ( ( resolve ) => {
420
- rl . question ( message , ( ) => {
427
+ rl . question ( "" , ( ) => {
421
428
rl . close ( ) ;
422
429
resolve ( ) ;
423
430
} ) ;
0 commit comments