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 22
33const argv = require ( 'yargs' ) . parse ( )
44const 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' )
86
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 ( ) => {
168 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 } )
1912
2013 const { Debugger, Runtime, Profiler} = client
2114 await Runtime . runIfWaitingForDebugger ( )
@@ -38,7 +31,7 @@ getPort().then(async port => {
3831 console . error ( err )
3932 process . exit ( 1 )
4033 }
41- } )
34+ } ) ( )
4235
4336async function outputCoverage ( Profiler ) {
4437 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 2323 "license" : " ISC" ,
2424 "dependencies" : {
2525 "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" ,
2926 "yargs" : " ^10.0.3"
3027 },
3128 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments