mirror of https://github.com/lukechilds/node.git
Browse Source
The command line flag `--debug-brk` was ignored when the `-e` flag was also present. This change allows the flags to both be honored when they are used in a single command line. PR-URL: https://github.com/nodejs/node/pull/7089 Fixes: https://github.com/nodejs/node/issues/3589 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>v6.x
committed by
Evan Lucas
10 changed files with 81 additions and 46 deletions
@ -1,9 +1,35 @@ |
|||||
'use strict'; |
'use strict'; |
||||
|
|
||||
const common = require('../common'); |
const common = require('../common'); |
||||
const assert = require('assert'); |
const spawn = require('child_process').spawn; |
||||
const spawnSync = require('child_process').spawnSync; |
|
||||
|
|
||||
const args = [`--debug-brk=${common.PORT}`, '-e', '0']; |
var procStderr = ''; |
||||
const proc = spawnSync(process.execPath, args, {encoding: 'utf8'}); |
var agentStdout = ''; |
||||
assert(/Debugger listening on/.test(proc.stderr)); |
var needToSpawnAgent = true; |
||||
|
var needToExit = true; |
||||
|
|
||||
|
const procArgs = [`--debug-brk=${common.PORT}`, '-e', '0']; |
||||
|
const proc = spawn(process.execPath, procArgs); |
||||
|
proc.stderr.setEncoding('utf8'); |
||||
|
|
||||
|
const exitAll = common.mustCall((processes) => { |
||||
|
processes.forEach((myProcess) => { myProcess.kill(); }); |
||||
|
}); |
||||
|
|
||||
|
proc.stderr.on('data', (chunk) => { |
||||
|
procStderr += chunk; |
||||
|
if (/Debugger listening on/.test(procStderr) && needToSpawnAgent) { |
||||
|
needToSpawnAgent = false; |
||||
|
const agentArgs = ['debug', `localhost:${common.PORT}`]; |
||||
|
const agent = spawn(process.execPath, agentArgs); |
||||
|
agent.stdout.setEncoding('utf8'); |
||||
|
|
||||
|
agent.stdout.on('data', (chunk) => { |
||||
|
agentStdout += chunk; |
||||
|
if (/connecting to .+ ok/.test(agentStdout) && needToExit) { |
||||
|
needToExit = false; |
||||
|
exitAll([proc, agent]); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
Loading…
Reference in new issue