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 <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 43ec938 commit 7c13e54

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/internal/modules/cjs/loader.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,12 @@ function readPackage(requestPath) {
153153
}
154154

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

165164
function tryPackage(requestPath, exts, isMain) {

0 commit comments

Comments
 (0)