@@ -15,57 +15,44 @@ const path = require('path');
15
15
const script = path . relative ( process . cwd ( ) , scriptFullPath ) ;
16
16
const cli = startCLI ( [ script ] ) ;
17
17
18
- function onFatal ( error ) {
19
- cli . quit ( ) ;
20
- throw error ;
21
- }
22
-
23
- cli . waitForInitialBreak ( )
24
- . then ( ( ) => cli . waitForPrompt ( ) )
25
- . then ( ( ) => {
18
+ ( async ( ) => {
19
+ try {
20
+ await cli . waitForInitialBreak ( ) ;
21
+ await cli . waitForPrompt ( ) ;
22
+ await cli . waitForPrompt ( ) ;
26
23
assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
27
- } )
28
- // Making sure it will die by default:
29
- . then ( ( ) => cli . command ( 'c' ) )
30
- . then ( ( ) => cli . waitFor ( / d i s c o n n e c t / ) )
31
24
32
- // Next run: With `breakOnException` it pauses in both places.
33
- . then ( ( ) => cli . stepCommand ( 'r' ) )
34
- . then ( ( ) => cli . waitForInitialBreak ( ) )
35
- . then ( ( ) => {
25
+ // Making sure it will die by default:
26
+ await cli . command ( 'c' ) ;
27
+ await cli . waitFor ( / d i s c o n n e c t / ) ;
28
+
29
+ // Next run: With `breakOnException` it pauses in both places.
30
+ await cli . stepCommand ( 'r' ) ;
31
+ await cli . waitForInitialBreak ( ) ;
36
32
assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
37
- } )
38
- . then ( ( ) => cli . command ( 'breakOnException' ) )
39
- . then ( ( ) => cli . stepCommand ( 'c' ) )
40
- . then ( ( ) => {
33
+ await cli . command ( 'breakOnException' ) ;
34
+ await cli . stepCommand ( 'c' ) ;
41
35
assert . ok ( cli . output . includes ( `exception in ${ script } :3` ) ) ;
42
- } )
43
- . then ( ( ) => cli . stepCommand ( 'c' ) )
44
- . then ( ( ) => {
36
+ await cli . stepCommand ( 'c' ) ;
45
37
assert . ok ( cli . output . includes ( `exception in ${ script } :9` ) ) ;
46
- } )
47
38
48
- // Next run: With `breakOnUncaught` it only pauses on the 2nd exception.
49
- . then ( ( ) => cli . command ( 'breakOnUncaught' ) )
50
- . then ( ( ) => cli . stepCommand ( 'r' ) ) // Also, the setting survives the restart.
51
- . then ( ( ) => cli . waitForInitialBreak ( ) )
52
- . then ( ( ) => {
39
+ // Next run: With `breakOnUncaught` it only pauses on the 2nd exception.
40
+ await cli . command ( 'breakOnUncaught' ) ;
41
+ await cli . stepCommand ( 'r' ) ; // Also, the setting survives the restart.
42
+ await cli . waitForInitialBreak ( ) ;
53
43
assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
54
- } )
55
- . then ( ( ) => cli . stepCommand ( 'c' ) )
56
- . then ( ( ) => {
44
+ await cli . stepCommand ( 'c' ) ;
57
45
assert . ok ( cli . output . includes ( `exception in ${ script } :9` ) ) ;
58
- } )
59
46
60
- // Next run: Back to the initial state! It should die again.
61
- . then ( ( ) => cli . command ( 'breakOnNone' ) )
62
- . then ( ( ) => cli . stepCommand ( 'r' ) )
63
- . then ( ( ) => cli . waitForInitialBreak ( ) )
64
- . then ( ( ) => {
47
+ // Next run: Back to the initial state! It should die again.
48
+ await cli . command ( 'breakOnNone' ) ;
49
+ await cli . stepCommand ( 'r' ) ;
50
+ await cli . waitForInitialBreak ( ) ;
65
51
assert . deepStrictEqual ( cli . breakInfo , { filename : script , line : 1 } ) ;
66
- } )
67
- . then ( ( ) => cli . command ( 'c' ) )
68
- . then ( ( ) => cli . waitFor ( / d i s c o n n e c t / ) )
69
- . then ( ( ) => cli . quit ( ) )
70
- . then ( null , onFatal ) ;
52
+ await cli . command ( 'c' ) ;
53
+ await cli . waitFor ( / d i s c o n n e c t / ) ;
54
+ } finally {
55
+ cli . quit ( ) ;
56
+ }
57
+ } ) ( ) . then ( common . mustCall ( ) ) ;
71
58
}
0 commit comments