-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: ensure relative requires work from deleted directories
PR-URL: #42384 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
2 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'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); |