• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const tmpdir = require('../common/tmpdir');
5const assert = require('assert');
6const fs = require('fs');
7const path = require('path');
8
9tmpdir.refresh();
10
11const fooPath = path.join(tmpdir.path, 'foo.cjs');
12fs.writeFileSync(fooPath, '');
13
14const dirPath = path.join(tmpdir.path, 'delete_me');
15fs.mkdirSync(dirPath, {
16  recursive: true
17});
18
19const barPath = path.join(dirPath, 'bar.cjs');
20fs.writeFileSync(barPath, `
21    module.exports = () => require('../foo.cjs').call()
22`);
23
24const foo = require(fooPath);
25const unique = Symbol('unique');
26foo.call = common.mustCall(() => unique);
27const bar = require(barPath);
28
29fs.rmSync(dirPath, { recursive: true });
30assert.strict.equal(bar(), unique);
31