Skip to content

Commit

Permalink
Fix debugging with Webstorm on Node.js 8 (#1414)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dohomi authored and novemberborn committed Jun 25, 2017
1 parent 212b5de commit a868b02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a868b02

Please sign in to comment.