Skip to content

Commit

Permalink
module: simplify tryStatSync with throwIfNoEntry option
Browse files Browse the repository at this point in the history
PR-URL: #36971
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
aduh95 authored and targos committed Jun 11, 2021
1 parent 25eb720 commit 77c7d97
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/internal/modules/esm/resolve.js
Expand Up @@ -74,13 +74,8 @@ function getConditionsSet(conditions) {
const realpathCache = new SafeMap();
const packageJSONCache = new SafeMap(); /* string -> PackageConfig */

function tryStatSync(path) {
try {
return statSync(path);
} catch {
return new Stats();
}
}
const tryStatSync =
(path) => statSync(path, { throwIfNoEntry: false }) ?? new Stats();

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

0 comments on commit 77c7d97

Please sign in to comment.