diff --git a/api.js b/api.js index e5c5a7b92..0179affbb 100644 --- a/api.js +++ b/api.js @@ -171,9 +171,9 @@ class Api extends EventEmitter { const execArgv = this.options.testOnlyExecArgv || process.execArgv; let debugArgIndex = -1; - // --debug-brk is used in addition to --inspect to break on first line and wait + // --inspect-brk is used in addition to --inspect to break on first line and wait execArgv.some((arg, index) => { - const isDebugArg = arg === '--inspect' || arg.indexOf('--inspect=') === 0; + const isDebugArg = /^--inspect(-brk)?($|=)/.test(arg); if (isDebugArg) { debugArgIndex = index; } @@ -184,7 +184,7 @@ class Api extends EventEmitter { const isInspect = debugArgIndex >= 0; if (!isInspect) { execArgv.some((arg, index) => { - const isDebugArg = arg === '--debug' || arg === '--debug-brk' || arg.indexOf('--debug-brk=') === 0 || arg.indexOf('--debug=') === 0; + const isDebugArg = /^--debug(-brk)?($|=)/.test(arg); if (isDebugArg) { debugArgIndex = index; } diff --git a/test/api.js b/test/api.js index 871975874..37a6cec96 100644 --- a/test/api.js +++ b/test/api.js @@ -1049,9 +1049,11 @@ generatePassDebugTests(['--debug'], -1); generatePassDebugTests(['--inspect=0'], 0); generatePassDebugTests(['--inspect'], 0); +// --inspect takes precedence generatePassDebugTests(['--inspect=0', '--debug-brk'], 0); generatePassDebugTests(['--inspect', '--debug-brk'], 0); +// --inspect takes precedence, though --debug-brk is still passed to the worker generatePassDebugTests(['--debug-brk', '--inspect=0'], 1); generatePassDebugTests(['--debug-brk', '--inspect'], 1);