1
- 'use strict' ;
2
- const common = require ( '../common' ) ;
3
- const startCLI = require ( '../common/debugger' ) ;
1
+ import { skipIfInspectorDisabled , mustCall } from '../common/index.mjs' ;
4
2
5
- common . skipIfInspectorDisabled ( ) ;
3
+ skipIfInspectorDisabled ( ) ;
6
4
7
- const assert = require ( 'assert' ) ;
8
- const http = require ( 'http' ) ;
5
+ import startCLI from '../common/debugger.js' ;
6
+
7
+ import assert from 'assert' ;
8
+ import http from 'http' ;
9
9
10
10
const host = '127.0.0.1' ;
11
11
@@ -14,14 +14,16 @@ const host = '127.0.0.1';
14
14
res . statusCode = 400 ;
15
15
res . end ( 'Bad Request' ) ;
16
16
} ) ;
17
- server . listen ( 0 , common . mustCall ( ( ) => {
17
+
18
+ server . listen ( 0 , mustCall ( async ( ) => {
18
19
const port = server . address ( ) . port ;
19
20
const cli = startCLI ( [ `${ host } :${ port } ` ] ) ;
20
- cli . quit ( ) . then ( common . mustCall ( ( code ) => {
21
+ try {
22
+ const code = await cli . quit ( ) ;
21
23
assert . strictEqual ( code , 1 ) ;
22
- } ) ) . finally ( ( ) => {
24
+ } finally {
23
25
server . close ( ) ;
24
- } ) ;
26
+ }
25
27
} ) ) ;
26
28
}
27
29
@@ -30,13 +32,15 @@ const host = '127.0.0.1';
30
32
res . statusCode = 200 ;
31
33
res . end ( 'some data that is invalid json' ) ;
32
34
} ) ;
33
- server . listen ( 0 , host , common . mustCall ( ( ) => {
35
+
36
+ server . listen ( 0 , host , mustCall ( async ( ) => {
34
37
const port = server . address ( ) . port ;
35
38
const cli = startCLI ( [ `${ host } :${ port } ` ] ) ;
36
- cli . quit ( ) . then ( common . mustCall ( ( code ) => {
39
+ try {
40
+ const code = await cli . quit ( ) ;
37
41
assert . strictEqual ( code , 1 ) ;
38
- } ) ) . finally ( ( ) => {
42
+ } finally {
39
43
server . close ( ) ;
40
- } ) ;
44
+ }
41
45
} ) ) ;
42
46
}
0 commit comments