Skip to content

Commit

Permalink
Rebase on the branch of pr #8 and fix test failures in old nodejs.
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk committed Dec 10, 2017
1 parent 78000dc commit 3df3f30
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function (flags, argv, forcedFlags, execute) {

var index = argv.indexOf(FORBID_RESPAWNING_FLAG);
if (index >= 0) {
argv = remover([FORBID_RESPAWNING_FLAG], argv);
argv = argv.slice(0, index).concat(argv.slice(index + 1));
argv = remover(flags, argv);
execute(true, process, argv);
return;
Expand Down
4 changes: 3 additions & 1 deletion lib/remover.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const isV8flags = require('./is-v8flags');

module.exports = function(flags, argv) {
var args = argv.slice(0, 1);
for (var i = 1, n = argv.length; i < n; i++) {
var arg = argv[i];
var flag = arg.split('=')[0];
if (flags.indexOf(flag) < 0) {
if (!isV8flags(flag, flags)) {
args.push(arg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/bin/force-and-forbid-respawning.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ v8flags(function(err, flags) {

var argv = process.argv.concat('--no-respawning');

flaggedRespawn(flags, argv, ['--trace-warnings'], function (ready, child) {
flaggedRespawn(flags, argv, ['--trace-deprecation'], function (ready, child) {
if (ready) {
console.log('Running!');
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/bin/force-respawning.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ v8flags(function(err, flags) {
return;
}

flaggedRespawn(flags, process.argv, ['--trace-warnings'], function (ready, child) {
flaggedRespawn(flags, process.argv, ['--trace-deprecation'], function (ready, child) {
if (ready) {
console.log('Running!');
} else {
Expand Down
4 changes: 3 additions & 1 deletion test/bin/print-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ v8flags(function(err, flags) {
}

flaggedRespawn(flags, process.argv, [
'--trace-warnings',
'--trace-deprecation',
/*
'--require',
'v8flags',
'--v8-pool-size=2',
*/
], function (ready, child, args) {
if (ready) {
console.log('cli args passed to app:', args.join(' '));
Expand Down
9 changes: 5 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,19 @@ describe('flaggedRespawn', function () {
});

describe('cli args which are passed to app', function() {

it('should pass args except v8flags, forced node flags, --no-respawning when respawned', function(done) {
var script = path.resolve(__dirname, 'bin/print-args.js');
var cmd = [
'node',
process.argv[0],
script,
'aaa',
'--harmony',
'-q',
'1234',
'--cwd',
'bbb/ccc/ddd',
'--experimental_extras',
'--prof_browser_mode',
'-V',
].join(' ');

Expand All @@ -260,15 +261,15 @@ describe('flaggedRespawn', function () {
it('should pass args except v8flags, forced node flags, --no-respawning when not respawned', function(done) {
var script = path.resolve(__dirname, 'bin/print-args.js');
var cmd = [
'node',
process.argv[0],
script,
'aaa',
'--harmony',
'-q',
'1234',
'--cwd',
'bbb/ccc/ddd',
'--experimental_extras',
'--prof-browser-mode',
'-V',
'--no-respawning',
].join(' ');;
Expand Down

0 comments on commit 3df3f30

Please sign in to comment.