0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-child-process-env.js

34 lines
639 B
JavaScript
Raw Normal View History

'use strict';
var common = require('../common');
2010-12-05 00:20:34 +01:00
var assert = require('assert');
2010-03-17 22:00:17 +01:00
var spawn = require('child_process').spawn;
var env = {
'HELLO': 'WORLD'
};
env.__proto__ = {
'FOO': 'BAR'
};
if (common.isWindows) {
2011-08-02 02:18:01 +02:00
var child = spawn('cmd.exe', ['/c', 'set'], {env: env});
2011-08-01 22:43:38 +02:00
} else {
var child = spawn('/usr/bin/env', [], {env: env});
}
2010-03-17 22:00:17 +01:00
var response = '';
2010-03-03 19:45:58 +01:00
2010-03-17 22:00:17 +01:00
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
2010-03-17 22:00:17 +01:00
response += chunk;
2010-03-03 19:45:58 +01:00
});
process.on('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
assert.ok(response.indexOf('FOO=BAR') >= 0);
2010-03-03 19:45:58 +01:00
});