Skip to content

Commit

Permalink
fix(std/node): resolve files in symlinked directories (denoland/deno#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Liamolucko authored Jan 5, 2021
1 parent 878399b commit a28e7f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
11 changes: 1 addition & 10 deletions node/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions node/module_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions node/tests/cjs/dir
4 changes: 4 additions & 0 deletions node/tests/cjs/subdir/dir/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// deno-lint-ignore-file no-undef
const C = require("../cjs_c");

module.exports = { C };

0 comments on commit a28e7f6

Please sign in to comment.