From 0fc159bac7fad9f3ee8bfe46e440b65f2fe71fd6 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 8 May 2018 09:49:45 +0200 Subject: [PATCH] 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. --- lib/internal/modules/cjs/loader.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 85ab3ab1443ded..8a4974225049ce 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -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) {