diff --git a/src/node_options-inl.h b/src/node_options-inl.h index 277121036e519d..468368ac84f630 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -253,7 +253,7 @@ struct ArgsInfo { // on the command line (i.e. not generated through alias expansion). // '--' is a special case here since its purpose is to end `exec_argv`, // which is why we do not include it. - if (exec_args != nullptr && first() != "--") + if (exec_args != nullptr && ret != "--") exec_args->push_back(ret); underlying->erase(underlying->begin() + 1); } else { diff --git a/test/parallel/test-process-exec-argv.js b/test/parallel/test-process-exec-argv.js index fec5699933d6f4..578ee7b5d1a5e3 100644 --- a/test/parallel/test-process-exec-argv.js +++ b/test/parallel/test-process-exec-argv.js @@ -27,16 +27,19 @@ const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { process.stdout.write(JSON.stringify(process.execArgv)); } else { - const execArgv = ['--stack-size=256']; - const args = [__filename, 'child', 'arg0']; - const child = spawn(process.execPath, execArgv.concat(args)); - let out = ''; + for (const extra of [ [], [ '--' ] ]) { + const execArgv = ['--stack-size=256']; + const args = [__filename, 'child', 'arg0']; + const child = spawn(process.execPath, [...execArgv, ...extra, ...args]); + let out = ''; - child.stdout.on('data', function(chunk) { - out += chunk; - }); + child.stdout.setEncoding('utf8'); + child.stdout.on('data', function(chunk) { + out += chunk; + }); - child.on('close', function() { - assert.deepStrictEqual(JSON.parse(out), execArgv); - }); + child.on('close', function() { + assert.deepStrictEqual(JSON.parse(out), execArgv); + }); + } }