mirror of
https://github.com/denoland/deno.git
synced 2025-09-28 13:14:48 +00: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 {
|
function toRealPath(requestPath: string): string {
|
||||||
// Deno does not have realpath implemented yet.
|
return Deno.realPathSync(requestPath);
|
||||||
let fullPath = requestPath;
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
fullPath = Deno.readLinkSync(fullPath);
|
|
||||||
} catch {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return path.resolve(requestPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a path, check if the file exists with any of the set extensions
|
// 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");
|
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
Add a link
Reference in a new issue