Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7c13e54

Browse filesBrowse 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
Copy full SHA for 7c13e54

File tree

Expand file treeCollapse file tree

1 file changed

+1
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-2
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: lib/internal/modules/cjs/loader.js
+1-2Lines 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-
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.