Skip to content

Commit 7c13e54

Browse files
danbevtargos
authored andcommitted
lib: return directly from packageMainCache
This commit updates readPackage to return directly when calling packageMainCache instead of storing the result in a local var and returning later. PR-URL: #20591 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 43ec938 commit 7c13e54

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

‎lib/internal/modules/cjs/loader.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,12 @@ function readPackage(requestPath) {
153153
}
154154

155155
try{
156-
varpkg=packageMainCache[requestPath]=JSON.parse(json).main;
156+
returnpackageMainCache[requestPath]=JSON.parse(json).main;
157157
}catch(e){
158158
e.path=jsonPath;
159159
e.message='Error parsing '+jsonPath+': '+e.message;
160160
throwe;
161161
}
162-
returnpkg;
163162
}
164163

165164
functiontryPackage(requestPath,exts,isMain){

0 commit comments

Comments
 (0)