Skip to content

Commit

Permalink
child_process: simplify argument handling
Browse files Browse the repository at this point in the history
This commit simplifies the calling of normalizeSpawnArguments()
and normalizeExecArguments(). Specifically, this commit replaces
apply() and the use of arguments with a normal function call.

PR-URL: nodejs#25194
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
cjihrig authored and refack committed Jan 10, 2019
1 parent 5a4fa54 commit 903a634
Showing 1 changed file with 13 additions and 13 deletions.
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);
var inheritStderr = !opts.options.stdio;

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

0 comments on commit 903a634

Please sign in to comment.