mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
966e3d3493
PR-URL: https://github.com/nodejs/node/pull/49128 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
31 lines
722 B
JavaScript
31 lines
722 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 = tmpdir.resolve('foo.cjs');
|
|
fs.writeFileSync(fooPath, '');
|
|
|
|
const dirPath = tmpdir.resolve('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);
|