module: simplify tryStatSync with throwIfNoEntry option

PR-URL: https://github.com/nodejs/node/pull/36971
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Antoine du Hamel
2021-01-16 20:05:26 +01:00
committed by James M Snell
parent 090f0cd7b6
commit 88153dc175

View File

@@ -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);