mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(std/node): resolve files in symlinked directories (#8840)
This commit is contained in:
parent
39bbbbce70
commit
4c4791b589
4 changed files with 11 additions and 10 deletions
|
@ -764,16 +764,7 @@ function tryFile(requestPath: string, _isMain: boolean): string | false {
|
|||
}
|
||||
|
||||
function toRealPath(requestPath: string): string {
|
||||
// Deno does not have realpath implemented yet.
|
||||
let fullPath = requestPath;
|
||||
while (true) {
|
||||
try {
|
||||
fullPath = Deno.readLinkSync(fullPath);
|
||||
} catch {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return path.resolve(requestPath);
|
||||
return Deno.realPathSync(requestPath);
|
||||
}
|
||||
|
||||
// Given a path, check if the file exists with any of the set extensions
|
||||
|
|
|
@ -69,3 +69,8 @@ Deno.test("requireStack", function () {
|
|||
assertStringIncludes(e.stack, "/tests/cjs/cjs_throw.js");
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test("requireFileInSymlinkDir", () => {
|
||||
const { C } = require("./tests/cjs/dir");
|
||||
assertEquals(C, "C");
|
||||
});
|
||||
|
|
1
std/node/tests/cjs/dir
Symbolic link
1
std/node/tests/cjs/dir
Symbolic link
|
@ -0,0 +1 @@
|
|||
./subdir/dir
|
4
std/node/tests/cjs/subdir/dir/index.js
Normal file
4
std/node/tests/cjs/subdir/dir/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
// deno-lint-ignore-file no-undef
|
||||
const C = require("../cjs_c");
|
||||
|
||||
module.exports = { C };
|
Loading…
Add table
Reference in a new issue