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 <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
7a867b8140
commit
acb49dc04d
@ -147,8 +147,8 @@ function normalizeExecArgs(command, options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
exports.exec = function exec(/* command , options, callback */) {
|
exports.exec = function exec(command, options, callback) {
|
||||||
const opts = normalizeExecArgs.apply(null, arguments);
|
const opts = normalizeExecArgs(command, options, callback);
|
||||||
return exports.execFile(opts.file,
|
return exports.execFile(opts.file,
|
||||||
opts.options,
|
opts.options,
|
||||||
opts.callback);
|
opts.callback);
|
||||||
@ -537,11 +537,11 @@ function normalizeSpawnArguments(file, args, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var spawn = exports.spawn = function spawn(/* file, args, options */) {
|
var spawn = exports.spawn = function spawn(file, args, options) {
|
||||||
var opts = normalizeSpawnArguments.apply(null, arguments);
|
const opts = normalizeSpawnArguments(file, args, options);
|
||||||
var options = opts.options;
|
const child = new ChildProcess();
|
||||||
var child = new ChildProcess();
|
|
||||||
|
|
||||||
|
options = opts.options;
|
||||||
debug('spawn', opts.args, options);
|
debug('spawn', opts.args, options);
|
||||||
|
|
||||||
child.spawn({
|
child.spawn({
|
||||||
@ -560,10 +560,10 @@ var spawn = exports.spawn = function spawn(/* file, args, options */) {
|
|||||||
return child;
|
return child;
|
||||||
};
|
};
|
||||||
|
|
||||||
function spawnSync(/* file, args, options */) {
|
function spawnSync(file, args, options) {
|
||||||
var opts = normalizeSpawnArguments.apply(null, arguments);
|
const opts = normalizeSpawnArguments(file, args, options);
|
||||||
|
|
||||||
var options = opts.options;
|
options = opts.options;
|
||||||
|
|
||||||
debug('spawnSync', opts.args, options);
|
debug('spawnSync', opts.args, options);
|
||||||
|
|
||||||
@ -631,8 +631,8 @@ function checkExecSyncError(ret, args, cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function execFileSync(/* command, args, options */) {
|
function execFileSync(command, args, options) {
|
||||||
var opts = normalizeSpawnArguments.apply(null, arguments);
|
var opts = normalizeSpawnArguments(command, args, options);
|
||||||
var inheritStderr = !opts.options.stdio;
|
var inheritStderr = !opts.options.stdio;
|
||||||
|
|
||||||
var ret = spawnSync(opts.file, opts.args.slice(1), opts.options);
|
var ret = spawnSync(opts.file, opts.args.slice(1), opts.options);
|
||||||
@ -650,8 +650,8 @@ function execFileSync(/* command, args, options */) {
|
|||||||
exports.execFileSync = execFileSync;
|
exports.execFileSync = execFileSync;
|
||||||
|
|
||||||
|
|
||||||
function execSync(command /* , options */) {
|
function execSync(command, options) {
|
||||||
var opts = normalizeExecArgs.apply(null, arguments);
|
var opts = normalizeExecArgs(command, options, null);
|
||||||
var inheritStderr = !opts.options.stdio;
|
var inheritStderr = !opts.options.stdio;
|
||||||
|
|
||||||
var ret = spawnSync(opts.file, opts.options);
|
var ret = spawnSync(opts.file, opts.options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user