Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

child_process: simplify argument handling #25194

Merged
merged 1 commit into from
Dec 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ function normalizeExecArgs(command, options, callback) {
}


exports.exec = function exec(/* command , options, callback */) {
const opts = normalizeExecArgs.apply(null, arguments);
exports.exec = function exec(command, options, callback) {
const opts = normalizeExecArgs(command, options, callback);
return exports.execFile(opts.file,
opts.options,
opts.callback);
Expand Down Expand Up @@ -537,11 +537,11 @@ function normalizeSpawnArguments(file, args, options) {
}


var spawn = exports.spawn = function spawn(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var options = opts.options;
var child = new ChildProcess();
var spawn = exports.spawn = function spawn(file, args, options) {
const opts = normalizeSpawnArguments(file, args, options);
const child = new ChildProcess();

options = opts.options;
debug('spawn', opts.args, options);

child.spawn({
Expand All @@ -560,10 +560,10 @@ var spawn = exports.spawn = function spawn(/* file, args, options */) {
return child;
};

function spawnSync(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
function spawnSync(file, args, options) {
const opts = normalizeSpawnArguments(file, args, options);

var options = opts.options;
options = opts.options;

debug('spawnSync', opts.args, options);

Expand Down Expand Up @@ -631,8 +631,8 @@ function checkExecSyncError(ret, args, cmd) {
}


function execFileSync(/* command, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
function execFileSync(command, args, options) {
var opts = normalizeSpawnArguments(command, args, options);
var inheritStderr = !opts.options.stdio;

var ret = spawnSync(opts.file, opts.args.slice(1), opts.options);
Expand All @@ -650,8 +650,8 @@ function execFileSync(/* command, args, options */) {
exports.execFileSync = execFileSync;


function execSync(command /* , options */) {
var opts = normalizeExecArgs.apply(null, arguments);
function execSync(command, options) {
var opts = normalizeExecArgs(command, options, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to remove null as it's not required but by passing it through explicitly it somewhat seems like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last I heard, it was still better to pass the exact number of expected arguments. If that has changed, I'm happy to remove the optional parameter.

var inheritStderr = !opts.options.stdio;

var ret = spawnSync(opts.file, opts.options);
Expand Down