• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4
5const { spawn } = require('child_process');
6for (const args of [[], ['-']]) {
7  const child = spawn(process.execPath, args, {
8    env: { ...process.env,
9           NODE_DEBUG: process.argv[2] }
10  });
11  const wanted = `${child.pid}\n`;
12  let found = '';
13
14  child.stdout.setEncoding('utf8');
15  child.stdout.on('data', function(c) {
16    found += c;
17  });
18
19  child.stderr.setEncoding('utf8');
20  child.stderr.on('data', function(c) {
21    console.error(`> ${c.trim().split('\n').join('\n> ')}`);
22  });
23
24  child.on('close', common.mustCall(function(c) {
25    assert.strictEqual(c, 0);
26    assert.strictEqual(found, wanted);
27  }));
28
29  setTimeout(function() {
30    child.stdin.end('console.log(process.pid)');
31  }, 1);
32}
33