Read up the prototype of the 'env' object.
authorNathan Rajlich <nathan@tootallnate.net>
Fri, 18 Feb 2011 21:44:20 +0000 (13:44 -0800)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 25 Feb 2011 00:36:23 +0000 (16:36 -0800)
Closes GH-713.

lib/child_process.js
test/simple/test-child-process-env.js

index fd4a314..2de11d6 100644 (file)
@@ -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]);
   }
 
index e28a605..1f5ffef 100644 (file)
@@ -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);
 });