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 ruyadorno committed Jan 25, 2021
1 parent 7ea374b commit 5290d63
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 @@ -104,13 +104,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 5290d63

Please sign in to comment.