Skip to content

Commit

Permalink
fix avajs#342 set child process debug port to available
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 18, 2016
1 parent 3754db3 commit 0915c6e
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,14 @@ Api.prototype._run = function (files, _options) {
Api.prototype.computeForkExecArgs = function (files) {
var execArgv = this.options.testOnlyExecArgv || process.execArgv;
var debugArgIndex = -1;

// --debug-brk is used in addition to --inspect to break on first line and wait
execArgv.some(function (arg, index) {
if (arg === '--inspect' || arg.indexOf('--inspect=') === 0) {
if (arg === '--debug' || arg === '--debug-brk' || arg.indexOf('--debug-brk=') === 0 || arg.indexOf('--debug=') === 0) {
debugArgIndex = index;
return true;
}
return false;
});

var isInspect = debugArgIndex !== -1;
if (!isInspect) {
execArgv.some(function (arg, index) {
if (arg === '--debug' || arg === '--debug-brk' || arg.indexOf('--debug-brk=') === 0 || arg.indexOf('--debug=') === 0) {
debugArgIndex = index;
return true;
}
return false;
});
}

if (debugArgIndex === -1) {
return Promise.resolve([]);
}
Expand All @@ -162,7 +149,7 @@ Api.prototype.computeForkExecArgs = function (files) {
.then(function (ports) {
return ports.map(function (port) {
var forkExecArgv = execArgv.slice();
var flagName = isInspect ? '--inspect' : '--debug';
var flagName = '--debug';
var oldValue = forkExecArgv[debugArgIndex];
if (oldValue.indexOf('brk') > 0) {
flagName += '-brk';
Expand Down

0 comments on commit 0915c6e

Please sign in to comment.