@@ -40,32 +40,33 @@ export async function withSpinners(
40
40
let currentLabel ! : string ;
41
41
let lastLogged ! : string ;
42
42
43
- try {
44
- for ( const [ label , run ] of tasks ) {
45
- currentLabel = label ;
43
+ for ( const [ label , run ] of tasks ) {
44
+ currentLabel = label ;
46
45
47
- const line = makeLine ( chalk . gray ( ` - ${ label } ` ) ) ;
48
- const stopWriting = startLineWithDots ( line ) ;
46
+ const line = makeLine ( chalk . gray ( ` - ${ label } ` ) ) ;
47
+ const stopWriting = startLineWithDots ( line ) ;
49
48
49
+ try {
50
50
await run ( ) ;
51
+ } catch ( error ) {
52
+ const descriptor = `${ lowerFirst ( label ) } > ${ lowerFirst ( currentLabel ) } ` ;
51
53
52
- const lineLength = stopWriting ( ) ;
53
- lastLogged = chalk . gray ( `${ line } ✔️\n` ) ;
54
+ logLine ( chalk . red ( `❌ Error ${ descriptor } .` ) ) ;
54
55
56
+ throw new Error ( `Failed ${ descriptor } ` , { cause : error } ) ;
57
+ } finally {
58
+ const lineLength = stopWriting ( ) ;
55
59
readline . clearLine ( process . stdout , - 1 ) ;
56
60
readline . moveCursor ( process . stdout , - lineLength , 0 ) ;
57
- process . stdout . write ( lastLogged ) ;
58
61
}
59
62
60
- readline . moveCursor ( process . stdout , - lastLogged . length , - tasks . length - 2 ) ;
61
- readline . clearScreenDown ( process . stdout ) ;
63
+ lastLogged = chalk . gray ( `${ line } ✔️\n` ) ;
62
64
63
- logNewSection ( chalk . green ( `✅ Passed ${ lowerFirst ( label ) } .` ) ) ;
64
- } catch ( error ) {
65
- const descriptor = `${ lowerFirst ( label ) } > ${ lowerFirst ( currentLabel ) } ` ;
65
+ process . stdout . write ( lastLogged ) ;
66
+ }
66
67
67
- logLine ( chalk . red ( `❌ Error ${ descriptor } .` ) ) ;
68
+ readline . moveCursor ( process . stdout , - lastLogged . length , - tasks . length - 2 ) ;
69
+ readline . clearScreenDown ( process . stdout ) ;
68
70
69
- throw new Error ( `Failed ${ descriptor } ` , { cause : error } ) ;
70
- }
71
+ logNewSection ( chalk . green ( `✅ Passed ${ lowerFirst ( label ) } .` ) ) ;
71
72
}
0 commit comments