0
0
Fork 0
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:
Liam Murphy 2021-01-06 10:42:40 +11:00 committed by GitHub
parent 39bbbbce70
commit 4c4791b589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 10 deletions

View file

@ -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

View file

@ -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
View file

@ -0,0 +1 @@
./subdir/dir

View file

@ -0,0 +1,4 @@
// deno-lint-ignore-file no-undef
const C = require("../cjs_c");
module.exports = { C };