Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

child_process: clone spawn options argument #9159

Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ function normalizeSpawnArguments(file /*, args, options*/) {
else if (!util.isObject(options))
throw new TypeError('options argument must be an object');

options = util._extend({}, options);

Choose a reason for hiding this comment

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

is this basically to shallow clone options?

args.unshift(file);

var env = options.env || process.env;
Expand Down
11 changes: 11 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ exports.spawnCat = function(options) {
};


exports.spawnSyncCat = function(options) {
var spawnSync = require('child_process').spawnSync;

if (process.platform === 'win32') {
return spawnSync('more', [], options);
} else {
return spawnSync('cat', [], options);
}
};


exports.spawnPwd = function(options) {
var spawn = require('child_process').spawn;

Expand Down
4 changes: 4 additions & 0 deletions test/simple/test-child-process-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ child = common.spawnPwd(options);

assert.equal(child.stdout, null);
assert.equal(child.stderr, null);

options = {stdio: 'ignore'};
child = common.spawnSyncCat(options);
assert.deepEqual(options, {stdio: 'ignore'});