mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

Load self referential modules from the repl and using the preload flag `-r`. In both cases the base path used for resolution is the current `process.cwd()`. Also fixes an internal cycle bug in the REPL exports resolution. PR-URL: https://github.com/nodejs/node/pull/32261 Fixes: https://github.com/nodejs/node/issues/31595 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
21 lines
589 B
JavaScript
21 lines
589 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
const { exec } = require('child_process');
|
|
|
|
const nodeBinary = process.argv[0];
|
|
|
|
if (!common.isMainThread)
|
|
common.skip('process.chdir is not available in Workers');
|
|
|
|
const selfRefModule = fixtures.path('self_ref_module');
|
|
const fixtureA = fixtures.path('printA.js');
|
|
|
|
exec(`"${nodeBinary}" -r self_ref "${fixtureA}"`, { cwd: selfRefModule },
|
|
(err, stdout, stderr) => {
|
|
assert.ifError(err);
|
|
assert.strictEqual(stdout, 'A\n');
|
|
});
|