• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const child_process = require('child_process');
4const assert = require('assert');
5
6// Regression test for https://github.com/nodejs/node/issues/27575:
7// module.id === '<repl>' in the REPL.
8
9for (const extraFlags of [[], ['-e', '42']]) {
10  const flags = ['--interactive', ...extraFlags];
11  const proc = child_process.spawn(process.execPath, flags, {
12    stdio: ['pipe', 'pipe', 'inherit']
13  });
14  proc.stdin.write('module.id\n.exit\n');
15
16  let stdout = '';
17  proc.stdout.setEncoding('utf8');
18  proc.stdout.on('data', (chunk) => stdout += chunk);
19  proc.stdout.on('end', common.mustCall(() => {
20    assert(stdout.includes('<repl>'), `stdout: ${stdout}`);
21  }));
22}
23