Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
danbev committed May 8, 2018
commit 0fc159bac7fad9f3ee8bfe46e440b65f2fe71fd6
3 changes: 1 addition & 2 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,12 @@ function readPackage(requestPath) {
}

try {
var pkg = packageMainCache[requestPath] = JSON.parse(json).main;
return packageMainCache[requestPath] = JSON.parse(json).main;
} catch (e) {
e.path = jsonPath;
e.message = 'Error parsing ' + jsonPath + ': ' + e.message;
throw e;
}
return pkg;
}

function tryPackage(requestPath, exts, isMain) {
Expand Down