0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-28 22:46:31 +01:00
nodejs/test/parallel/test-child-process-env.js

35 lines
665 B
JavaScript
Raw Normal View History

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;
2011-08-01 22:43:38 +02:00
var isWindows = process.platform === 'win32';
var env = {
'HELLO': 'WORLD'
};
env.__proto__ = {
'FOO': 'BAR'
};
2011-08-01 22:43:38 +02:00
if (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
});