Skip to content

Commit 543ecbd

Browse files
aduh95ruyadorno
authored andcommitted
module: simplify tryStatSync with throwIfNoEntry option
PR-URL: #36971 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5693ed9 commit 543ecbd

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/internal/modules/esm/resolve.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ function getConditionsSet(conditions) {
104104
const realpathCache = new SafeMap();
105105
const packageJSONCache = new SafeMap(); /* string -> PackageConfig */
106106

107-
function tryStatSync(path) {
108-
try {
109-
return statSync(path);
110-
} catch {
111-
return new Stats();
112-
}
113-
}
107+
const tryStatSync =
108+
(path) => statSync(path, { throwIfNoEntry: false }) ?? new Stats();
114109

115110
function getPackageConfig(path, specifier, base) {
116111
const existing = packageJSONCache.get(path);

0 commit comments

Comments
 (0)