@@ -42,7 +42,7 @@ const [ InspectClient, createRepl ] =
4242
4343const debuglog = util . debuglog ( 'inspect' ) ;
4444
45- const DEBUG_PORT_PATTERN = / ^ - - (?: d e b u g | i n s p e c t ) - p o r t = ( \d + ) $ / ;
45+ const DEBUG_PORT_PATTERN = / ^ - - (?: d e b u g | i n s p e c t ) (?: - p o r t | - b r k ) ? = ( \d { 1 , 5 } ) $ / ;
4646function getDefaultPort ( ) {
4747 for ( const arg of process . execArgv ) {
4848 const match = arg . match ( DEBUG_PORT_PATTERN ) ;
@@ -56,8 +56,7 @@ function getDefaultPort() {
5656function runScript ( script , scriptArgs , inspectPort , childPrint ) {
5757 return new Promise ( ( resolve ) => {
5858 const args = [
59- '--inspect' ,
60- `--debug-brk=${ inspectPort } ` ,
59+ `--inspect-brk=${ inspectPort } ` ,
6160 ] . concat ( [ script ] , scriptArgs ) ;
6261 const child = spawn ( process . execPath , args ) ;
6362 child . stdout . setEncoding ( 'utf8' ) ;
@@ -68,7 +67,7 @@ function runScript(script, scriptArgs, inspectPort, childPrint) {
6867 let output = '' ;
6968 function waitForListenHint ( text ) {
7069 output += text ;
71- if ( / c h r o m e - d e v t o o l s : \/ \/ / . test ( output ) ) {
70+ if ( / ^ D e b u g g e r l i s t e n i n g o n / . test ( output ) ) {
7271 child . stderr . removeListener ( 'data' , waitForListenHint ) ;
7372 resolve ( child ) ;
7473 }
@@ -295,6 +294,7 @@ function parseArgv([target, ...args]) {
295294
296295 const hostMatch = target . match ( / ^ ( [ ^ : ] + ) : ( \d + ) $ / ) ;
297296 const portMatch = target . match ( / ^ - - p o r t = ( \d + ) $ / ) ;
297+
298298 if ( hostMatch ) {
299299 // Connecting to remote debugger
300300 // `node-inspect localhost:9229`
@@ -303,16 +303,15 @@ function parseArgv([target, ...args]) {
303303 isRemote = true ;
304304 script = null ;
305305 } else if ( portMatch ) {
306- // Start debugger on custom port
307- // `node debug --port=8058 app .js`
306+ // start debugee on custom port
307+ // `node inspect --port=9230 script .js`
308308 port = parseInt ( portMatch [ 1 ] , 10 ) ;
309309 script = args [ 0 ] ;
310310 scriptArgs = args . slice ( 1 ) ;
311311 }
312312
313313 return {
314- host, port,
315- isRemote, script, scriptArgs,
314+ host, port, isRemote, script, scriptArgs,
316315 } ;
317316}
318317
0 commit comments