mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

This is a partial revert of
15157c3c3d
. This change lead to a
regression that broke require() in the CLI REPL, as imported
files were evaluated in a different context.
Refs: https://github.com/nodejs/node/pull/5703
Fixes: https://github.com/nodejs/node/issues/7788
PR-URL: https://github.com/nodejs/node/pull/7795
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
29 lines
924 B
JavaScript
29 lines
924 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cp = require('child_process');
|
|
const path = require('path');
|
|
const child = cp.spawn(process.execPath, ['--interactive']);
|
|
const fixture = path.join(common.fixturesDir, 'is-object.js').replace(/\\/g,
|
|
'/');
|
|
let output = '';
|
|
|
|
child.stdout.setEncoding('utf8');
|
|
child.stdout.on('data', (data) => {
|
|
output += data;
|
|
});
|
|
|
|
child.on('exit', common.mustCall(() => {
|
|
const results = output.split('\n').map((line) => {
|
|
return line.replace(/\w*>\w*/, '').trim();
|
|
});
|
|
|
|
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
|
|
}));
|
|
|
|
child.stdin.write('const isObject = (obj) => obj.constructor === Object;\n');
|
|
child.stdin.write('isObject({});\n');
|
|
child.stdin.write(`require('${fixture}').isObject({});\n`);
|
|
child.stdin.write('.exit');
|
|
child.stdin.end();
|