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

PR-URL: https://github.com/nodejs/node/pull/42384 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com>
31 lines
738 B
JavaScript
31 lines
738 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
tmpdir.refresh();
|
|
|
|
const fooPath = path.join(tmpdir.path, 'foo.cjs');
|
|
fs.writeFileSync(fooPath, '');
|
|
|
|
const dirPath = path.join(tmpdir.path, 'delete_me');
|
|
fs.mkdirSync(dirPath, {
|
|
recursive: true
|
|
});
|
|
|
|
const barPath = path.join(dirPath, 'bar.cjs');
|
|
fs.writeFileSync(barPath, `
|
|
module.exports = () => require('../foo.cjs').call()
|
|
`);
|
|
|
|
const foo = require(fooPath);
|
|
const unique = Symbol('unique');
|
|
foo.call = common.mustCall(() => unique);
|
|
const bar = require(barPath);
|
|
|
|
fs.rmSync(dirPath, { recursive: true });
|
|
assert.strict.equal(bar(), unique);
|