0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/parallel/test-child-process-env.js
Jackson Tian cc195bf37b tools: enable no-proto rule for linter
Enable `no-proto` in `.eslintrc`.

Use `Object.setPrototypeOf()` and `Object.getPrototypeOf()`
instead of.

PR-URL: https://github.com/nodejs/node/pull/5140
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-10 08:40:23 -08:00

35 lines
654 B
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var env = {
'HELLO': 'WORLD'
};
Object.setPrototypeOf(env, {
'FOO': 'BAR'
});
var child;
if (common.isWindows) {
child = spawn('cmd.exe', ['/c', 'set'], {env: env});
} else {
child = spawn('/usr/bin/env', [], {env: env});
}
var response = '';
child.stdout.setEncoding('utf8');
child.stdout.on('data', function(chunk) {
console.log('stdout: ' + chunk);
response += chunk;
});
process.on('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
assert.ok(response.indexOf('FOO=BAR') >= 0);
});