Skip to content
Permalink
Browse files

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: #25194
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
cjihrig authored and targos committed Dec 23, 2018
1 parent 7e2ae75 commit 56e7e4f0cdeee32a57538a24ea6013d25bb66a03
Showing with 13 additions and 13 deletions.
  1. +13 −13 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);
@@ -534,11 +534,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({
@@ -557,10 +557,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);

@@ -628,8 +628,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);
@@ -647,8 +647,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);

0 comments on commit 56e7e4f

Please sign in to comment.
You can’t perform that action at this time.