Skip to content

Commit

Permalink
do not fork if no node flags present
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull authored and juergba committed Jun 6, 2019
1 parent d02a096 commit 30b8406
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions bin/mocha
Expand Up @@ -120,30 +120,34 @@ if (nodeArgs.gc) {

debug('final node args', nodeArgs);

const args = [].concat(
unparseNodeFlags(nodeArgs),
mochaPath,
unparse(mochaArgs, {alias: aliases})
);
if (Object.keys(nodeArgs).length) {
const args = [].concat(
unparseNodeFlags(nodeArgs),
mochaPath,
unparse(mochaArgs, {alias: aliases})
);

debug(`exec ${process.execPath} w/ args:`, args);
debug(`exec ${process.execPath} w/ args:`, args);

const proc = spawn(process.execPath, args, {
stdio: 'inherit'
});
const proc = spawn(process.execPath, args, {
stdio: 'inherit'
});

proc.on('exit', (code, signal) => {
process.on('exit', () => {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
proc.on('exit', (code, signal) => {
process.on('exit', () => {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
});
});
});

// terminate children.
process.on('SIGINT', () => {
proc.kill('SIGINT'); // calls runner.abort()
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
});
// terminate children.
process.on('SIGINT', () => {
proc.kill('SIGINT'); // calls runner.abort()
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die.
});
} else {
require('../lib/cli/cli').main(unparse(mochaArgs, {alias: aliases}));
}

0 comments on commit 30b8406

Please sign in to comment.