Skip to content

Commit 543ecbd

Browse files
aduh95ruyadorno
authored andcommitted
module: simplify tryStatSync with throwIfNoEntry option
PR-URL: #36971 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5693ed9 commit 543ecbd

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎lib/internal/modules/esm/resolve.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ function getConditionsSet(conditions) {
104104
constrealpathCache=newSafeMap();
105105
constpackageJSONCache=newSafeMap();/* string -> PackageConfig */
106106

107-
functiontryStatSync(path){
108-
try{
109-
returnstatSync(path);
110-
}catch{
111-
returnnewStats();
112-
}
113-
}
107+
consttryStatSync=
108+
(path)=>statSync(path,{throwIfNoEntry: false})??newStats();
114109

115110
functiongetPackageConfig(path,specifier,base){
116111
constexisting=packageJSONCache.get(path);

0 commit comments

Comments
 (0)