Skip to content

Commit a868b02

Browse files
dohominovemberborn
authored andcommitted
Fix debugging with Webstorm on Node.js 8 (#1414)
* Rename confusing `--debug-brk` in code comment * Document curious test behavior around `--inspect` and `--debug` flags * Match `--debug` and `--inspect` args with regular expressions * Add `--inspect-brk` for Webstorm debugging
1 parent 212b5de commit a868b02

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

api.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ class Api extends EventEmitter {
171171
const execArgv = this.options.testOnlyExecArgv || process.execArgv;
172172
let debugArgIndex = -1;
173173

174-
// --debug-brk is used in addition to --inspect to break on first line and wait
174+
// --inspect-brk is used in addition to --inspect to break on first line and wait
175175
execArgv.some((arg, index) => {
176-
const isDebugArg = arg === '--inspect' || arg.indexOf('--inspect=') === 0;
176+
const isDebugArg = /^--inspect(-brk)?($|=)/.test(arg);
177177
if (isDebugArg) {
178178
debugArgIndex = index;
179179
}
@@ -184,7 +184,7 @@ class Api extends EventEmitter {
184184
const isInspect = debugArgIndex >= 0;
185185
if (!isInspect) {
186186
execArgv.some((arg, index) => {
187-
const isDebugArg = arg === '--debug' || arg === '--debug-brk' || arg.indexOf('--debug-brk=') === 0 || arg.indexOf('--debug=') === 0;
187+
const isDebugArg = /^--debug(-brk)?($|=)/.test(arg);
188188
if (isDebugArg) {
189189
debugArgIndex = index;
190190
}

test/api.js

+2
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,11 @@ generatePassDebugTests(['--debug'], -1);
10491049
generatePassDebugTests(['--inspect=0'], 0);
10501050
generatePassDebugTests(['--inspect'], 0);
10511051

1052+
// --inspect takes precedence
10521053
generatePassDebugTests(['--inspect=0', '--debug-brk'], 0);
10531054
generatePassDebugTests(['--inspect', '--debug-brk'], 0);
10541055

1056+
// --inspect takes precedence, though --debug-brk is still passed to the worker
10551057
generatePassDebugTests(['--debug-brk', '--inspect=0'], 1);
10561058
generatePassDebugTests(['--debug-brk', '--inspect'], 1);
10571059

0 commit comments

Comments
 (0)