Skip to content

Commit 77c7d97

Browse files
aduh95targos
authored andcommittedJun 11, 2021
module: simplify tryStatSync with throwIfNoEntry option
PR-URL: #36971 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 25eb720 commit 77c7d97

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
@@ -74,13 +74,8 @@ function getConditionsSet(conditions) {
7474
const realpathCache = new SafeMap();
7575
const packageJSONCache = new SafeMap(); /* string -> PackageConfig */
7676

77-
function tryStatSync(path) {
78-
try {
79-
return statSync(path);
80-
} catch {
81-
return new Stats();
82-
}
83-
}
77+
const tryStatSync =
78+
(path) => statSync(path, { throwIfNoEntry: false }) ?? new Stats();
8479

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

0 commit comments

Comments
 (0)
Please sign in to comment.