[Pkg-javascript-commits] [node-module-deps] 215/444: more aggressive 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 debc1136be641729972c72a9589b23870a567baa
Author: James Halliday <mail at substack.net>
Date: Fri May 9 15:14:09 2014 -0700
more aggressive package caching
---
index.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/index.js b/index.js
index 5c2379a..d898d89 100644
--- a/index.js
+++ b/index.js
@@ -338,11 +338,15 @@ Deps.prototype.lookupPackage = function (file, cb) {
var id = path.resolve(this.basedir, file);
var cached = this.pkgCache[id];
if (cached) return nextTick(cb, null, cached);
+ if (cached === false) return nextTick(cb, null, undefined);
var dirs = parents(path.dirname(file));
(function next () {
- if (dirs.length === 0) return cb(null, undefined);
+ if (dirs.length === 0) {
+ self.pkgCache[id] = false;
+ return cb(null, undefined);
+ }
var dir = dirs.shift();
if (dir.split('/').slice(-1)[0] === 'node_modules') {
return cb(null, undefined);
@@ -352,6 +356,7 @@ Deps.prototype.lookupPackage = function (file, cb) {
var cached = self.pkgCache[pkgfile];
if (cached) return nextTick(cb, null, cached);
+ else if (cached === false) return next();
var pcached = self.pkgFileCachePending[pkgfile];
if (pcached) return pcached.push(onpkg);
@@ -367,6 +372,7 @@ Deps.prototype.lookupPackage = function (file, cb) {
}
pkg.__dirname = dir;
+ self.pkgCache[pkgfile] = pkg;
self.pkgCache[id] = pkg;
onpkg(null, pkg);
});
@@ -379,7 +385,10 @@ Deps.prototype.lookupPackage = function (file, cb) {
}
if (err) cb(err)
else if (pkg) cb(null, pkg)
- else next()
+ else {
+ self.pkgCache[pkgfile] = false;
+ next();
+ }
}
})();
};
--
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