diff options
author | cjihrig <cjihrig@gmail.com> | 2015-01-23 17:18:55 -0500 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2015-08-27 16:03:33 -0400 |
commit | b5a0abcfdf2e9c933c6c37c58c8205b8f94f37f6 (patch) | |
tree | 26a9fdffbcf1795721b8f29853f873a8470bd273 | |
parent | 0363cf4a80a9599f6e0a4f9023a7acc7363e40e7 (diff) | |
download | node-b5a0abcfdf2e9c933c6c37c58c8205b8f94f37f6.tar.gz |
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>
-rw-r--r-- | lib/child_process.js | 1 | ||||
-rw-r--r-- | test/common.js | 11 | ||||
-rw-r--r-- | test/simple/test-child-process-stdio.js | 4 |
3 files changed, 16 insertions, 0 deletions
diff --git a/lib/child_process.js b/lib/child_process.js index 8b29132cb..bc1a909fd 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -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; diff --git a/test/common.js b/test/common.js index 783d82a87..478e2e92a 100644 --- a/test/common.js +++ b/test/common.js @@ -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; diff --git a/test/simple/test-child-process-stdio.js b/test/simple/test-child-process-stdio.js index 32da15f5f..ec59138db 100644 --- a/test/simple/test-child-process-stdio.js +++ b/test/simple/test-child-process-stdio.js @@ -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'}); |