[Pkg-javascript-commits] [node-module-deps] 214/444: more package caching

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:57 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-module-deps.

commit f2390360ad205d4f0d900f2ac78fbdba3e5398f8
Author: James Halliday <mail at substack.net>
Date:   Fri May 9 15:10:13 2014 -0700

    more package caching
---
 index.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/index.js b/index.js
index 4984c01..5c2379a 100644
--- a/index.js
+++ b/index.js
@@ -337,7 +337,7 @@ Deps.prototype.lookupPackage = function (file, cb) {
     
     var id = path.resolve(this.basedir, file);
     var cached = this.pkgCache[id];
-    if (cached) return process.nextTick(function () { cb(null, cached) });
+    if (cached) return nextTick(cb, null, cached);
     
     var dirs = parents(path.dirname(file));
     
@@ -350,9 +350,12 @@ Deps.prototype.lookupPackage = function (file, cb) {
         
         var pkgfile = path.join(dir, 'package.json');
         
-        var cached = self.pkgFileCachePending[pkgfile];
-        if (cached) return cached.push(onpkg);
-        cached = self.pkgFileCachePending[pkgfile] = [];
+        var cached = self.pkgCache[pkgfile];
+        if (cached) return nextTick(cb, null, cached);
+        
+        var pcached = self.pkgFileCachePending[pkgfile];
+        if (pcached) return pcached.push(onpkg);
+        pcached = self.pkgFileCachePending[pkgfile] = [];
         
         fs.readFile(pkgfile, function (err, src) {
             if (err) return onpkg();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-module-deps.git



More information about the Pkg-javascript-commits mailing list