Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Read up the prototype of the 'env' object.

Closes GH-713.
  • Loading branch information...
commit a9a252fda9054a90cd0be17ea1ea492c82c317c2 1 parent 8a50f23
@TooTallNate TooTallNate authored ry committed
Showing with 11 additions and 3 deletions.
  1. +1 −2  lib/child_process.js
  2. +10 −1 test/simple/test-child-process-env.js
View
3  lib/child_process.js
@@ -215,8 +215,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
var envPairs = [];
var keys = Object.keys(env);
- for (var index = 0, keysLength = keys.length; index < keysLength; index++) {
- var key = keys[index];
+ for (var key in env) {
envPairs.push(key + '=' + env[key]);
}
View
11 test/simple/test-child-process-env.js
@@ -2,7 +2,15 @@ var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
-var child = spawn('/usr/bin/env', [], {env: {'HELLO': 'WORLD'}});
+
+var env = {
+ 'HELLO': 'WORLD'
+};
+env.__proto__ = {
+ 'FOO': 'BAR'
+}
+
+var child = spawn('/usr/bin/env', [], {env: env});
var response = '';
@@ -15,4 +23,5 @@ child.stdout.addListener('data', function(chunk) {
process.addListener('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
+ assert.ok(response.indexOf('FOO=BAR') >= 0);
});
Please sign in to comment.
Something went wrong with that request. Please try again.