Skip to content
Snippets Groups Projects
Commit ce6916d2 authored by Jakob Moosbrugger's avatar Jakob Moosbrugger
Browse files

automatic change of debug port for child process

parent 9cb3c47e
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,31 @@ var Worker = function () {
options.cwd = process.cwd();
}
//get all debug related parameters
var debugVars = process.execArgv.filter(function (execArg) {
return (/(debug|inspect)/.test(execArg)
);
});
if (debugVars.lenght > 0) {
if (!options.execArgv) {
//if no execArgs are given copy all arguments
debugVars = process.execArgv;
options.execArgv = [];
}
var portIndex = debugVars.findIndex(function (debugArg) {
//get index of debug port specifier
return (/^--(debug|inspect)(-brk)?=\d*/.test(debugArg)
);
});
if (portIndex > 0) {
//set new port, ignore "-brk", it doesn't work
debugVars[portIndex] = (/^--debug/.test(debugVars[portIndex]) ? "--debug=" : "--inspect=") + process.debugPort + 1;
}
options.execArgv = options.execArgv.concat(debugVars);
}
this.child = fork(worker, args, options);
this.onerror = undefined;
this.onmessage = undefined;
......
......@@ -12,6 +12,27 @@ class Worker {
options.cwd = process.cwd();
}
//get all debug related parameters
var debugVars = process.execArgv.filter(execArg => {
return (/(debug|inspect)/).test(execArg);
});
if (debugVars.lenght > 0) {
if (!options.execArgv) { //if no execArgs are given copy all arguments
debugVars = process.execArgv;
options.execArgv = [];
}
let portIndex = debugVars.findIndex(debugArg => { //get index of debug port specifier
return (/^--(debug|inspect)(-brk)?\d*/).test(debugArg);
});
if (portIndex > 0) { //set new port, ignore "-brk", it doesn't work
debugVars[portIndex] = ((/^--debug/).test(debugVars[portIndex]) ? "--debug=" : "--inspect=") + process.debugPort + 1;
}
options.execArgv = options.execArgv.concat(debugVars);
}
this.child = fork(worker, args, options);
this.onerror = undefined;
this.onmessage = undefined;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment