Skip to content

Commit

Permalink
if options object is empty, use process env
Browse files Browse the repository at this point in the history
  • Loading branch information
polotek committed Sep 28, 2011
1 parent 771ba34 commit 426de1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/child_process.js
Expand Up @@ -219,7 +219,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
options.uid === undefined) {
// Deprecated API: (path, args, options, env, customFds)
cwd = '';
env = options || process.env;
env = process.env;
customFds = customFds || [-1, -1, -1];
setsid = false;
uid = -1;
Expand Down
12 changes: 12 additions & 0 deletions test/simple/test-child-process-env.js
Expand Up @@ -42,7 +42,19 @@ child.stdout.addListener('data', function(chunk) {
response += chunk;
});

var child2 = spawn('/usr/bin/env', [], {});
var response2 = '';

child2.stdout.setEncoding('utf8');

child2.stdout.addListener('data', function(chunk) {
console.log('stdout2: ' + chunk);
response2 += chunk;
});

process.addListener('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
assert.ok(response.indexOf('FOO=BAR') >= 0);

assert.ok(response2.indexOf('PATH=') >= 0);
});

0 comments on commit 426de1c

Please sign in to comment.