child_process: clone spawn options argument

spawnSync() modifies the options argument. This commit makes
a copy of options before any modifications occur.

PR-URL: https://github.com/joyent/node/pull/9159
Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
cjihrig authored and James M Snell committed 2015-08-27 16:03:33 -04:00
1 parent 0363cf4a80
commit b5a0abcfdf
3 files changed
+16

No files matched your search

+1
View File
@@ -967,6 +967,7 @@ function normalizeSpawnArguments(file /*, args, options*/) {
else if (!util.isObject(options))
throw new TypeError('options argument must be an object');
options = util._extend({}, options);
args.unshift(file);
var env = options.env || process.env;
+11
View File
@@ -99,6 +99,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;
+4
View File
@@ -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'});