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 5, 2021
1 parent 809b762 commit a280e99
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/internal/modules/esm/resolve.js
Original file line number Diff line number Diff line change
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 a280e99

Please sign in to comment.