mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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:
1 parent
0363cf4a80
commit
b5a0abcfdf
3 files changed
+16
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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'});
|
||||
Reference in new issue
Block a user