File tree Expand file tree Collapse file tree 3 files changed +39
-16
lines changed Expand file tree Collapse file tree 3 files changed +39
-16
lines changed Original file line number Diff line number Diff line change 2
2
3
3
const argv = require ( 'yargs' ) . parse ( )
4
4
const CRI = require ( 'chrome-remote-interface' )
5
- const getPort = require ( 'get-port' ) ;
6
- const foreground = require ( 'foreground-child' )
7
- const waitTillPortOpen = require ( 'wait-till-port-open' )
5
+ const spawn = require ( '../lib/spawn' )
8
6
9
- getPort ( ) . then ( async port => {
10
- foreground (
11
- [ 'node' , `--inspect-brk=${ port } ` ] . concat ( process . argv . slice ( 2 ) ) ,
12
- ( done ) => {
13
- console . info ( 'actually got here' )
14
- }
15
- )
7
+ ; ( async ( ) => {
16
8
try {
17
- await waitTillPortOpen ( port )
18
- const client = await CRI ( { port : port } )
9
+ info = await spawn ( process . execPath ,
10
+ [ `--inspect-brk=0` ] . concat ( process . argv . slice ( 2 ) ) )
11
+ const client = await CRI ( { port : info . port } )
19
12
20
13
const { Debugger, Runtime, Profiler} = client
21
14
await Runtime . runIfWaitingForDebugger ( )
@@ -38,7 +31,7 @@ getPort().then(async port => {
38
31
console . error ( err )
39
32
process . exit ( 1 )
40
33
}
41
- } )
34
+ } ) ( )
42
35
43
36
async function outputCoverage ( Profiler ) {
44
37
const IGNORED_PATHS = [
Original file line number Diff line number Diff line change
1
+ const { spawn} = require ( 'child_process' )
2
+
3
+ const debuggerRe = / D e b u g g e r l i s t e n i n g o n w s : \/ \/ [ ^ : ] * : ( [ ^ / ] * ) /
4
+
5
+ module . exports = function ( execPath , args = [ ] ) {
6
+ const info = {
7
+ port : - 1
8
+ }
9
+ return new Promise ( ( resolve , reject ) => {
10
+ const proc = spawn ( execPath , args , {
11
+ stdio : [ process . stdin , process . stdout , 'pipe' ] ,
12
+ env : process . env ,
13
+ cwd : process . cwd ( )
14
+ } ) ;
15
+
16
+ proc . stderr . on ( 'data' , ( outBuffer ) => {
17
+ const outString = outBuffer . toString ( 'utf8' )
18
+ const match = outString . match ( debuggerRe )
19
+ if ( match && ! info . url ) {
20
+ info . port = Number ( match [ 1 ] )
21
+ return resolve ( info )
22
+ } else {
23
+ console . error ( outString )
24
+ }
25
+ } )
26
+
27
+ proc . on ( 'close' , ( code ) => {
28
+ if ( info . port === - 1 ) {
29
+ return reject ( Error ( 'could not connect to inspector' ) )
30
+ }
31
+ } )
32
+ } )
33
+ }
Original file line number Diff line number Diff line change 23
23
"license" : " ISC" ,
24
24
"dependencies" : {
25
25
"chrome-remote-interface" : " ^0.25.2" ,
26
- "foreground-child" : " ^1.5.6" ,
27
- "get-port" : " ^3.2.0" ,
28
- "wait-till-port-open" : " ^1.0.0" ,
29
26
"yargs" : " ^10.0.3"
30
27
},
31
28
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments