summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-default-options.js
blob: 37e7ea7494670ec215f1859e2cd2971bc966d5d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const common = require('../common');
const assert = require('assert');

const spawn = require('child_process').spawn;

process.env.HELLO = 'WORLD';

let child;
if (common.isWindows) {
  child = spawn('cmd.exe', ['/c', 'set'], {});
} else {
  child = spawn('/usr/bin/env', [], {});
}

let 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,
            'spawn did not use process.env as default');
});