Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment debug port for each child process. #874

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion index.js
Expand Up @@ -558,7 +558,24 @@ Command.prototype.executeSubCommand = function(argv, args, unknown) {
if (isExplicitJS) {
args.unshift(bin);
// add executable arguments to spawn
args = (process.execArgv || []).concat(args);
args = ((process.execArgv && process.execArgv.map(function( v ) {

var debugPort, matches;

if( (matches = v.match(/^(--debug=|--debug-brk=|--inspect=|--inspect-brk=)(?:(\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b):)?(\d+)/)) && matches.length > 0 ){

debugPort = + matches[3];

if( ! Number.isFinite(debugPort) )
throw new Error('Debug port is not a finite number.');

return ( matches[2] ) ? matches[1] + matches[2] + ':' + (++debugPort) : matches[1] + (++debugPort);

}
else
return v;

})) || []).concat(args);

proc = spawn(process.argv[0], args, { stdio: 'inherit', customFds: [0, 1, 2] });
} else {
Expand Down