mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
James M Snell
parent
090f0cd7b6
commit
88153dc175
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user