From 89986d4b28ae44bc3fea1121e2fdbf66823dbfd1 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 23 Dec 2018 12:41:18 -0500 Subject: [PATCH] child_process: simplify argument handling 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: https://github.com/nodejs/node/pull/25194 Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/child_process.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 40b5e52d0dde6d..b784a56814c0cc 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -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); @@ -529,11 +529,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({ @@ -552,10 +552,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); @@ -623,8 +623,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); @@ -642,8 +642,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);