From e9f8ab3cd6324fbf2678132324d4cd8579209442 Mon Sep 17 00:00:00 2001 From: Forrest L Norvell Date: Wed, 21 Jan 2015 18:12:40 -0800 Subject: npm-registry-client@6.0.0 * support /-/package/:name/access endpoint * support /-/package/:name/dist-tags endpoint * mandatory `access` parameter for publishes, with no default (because the client doesn't know which is appropriate). * registry client has atypical inheritance, so npm.client.distTags.* can be in their own little namespace. --- lib/cache/caching-client.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/cache/caching-client.js b/lib/cache/caching-client.js index 459a236f5..ec8eb8e16 100644 --- a/lib/cache/caching-client.js +++ b/lib/cache/caching-client.js @@ -24,6 +24,7 @@ function CachingRegistryClient (config) { // swizzle in our custom cache invalidation logic this._request = this.request this.request = this._invalidatingRequest + this.get = get } inherits(CachingRegistryClient, RegistryClient) @@ -42,7 +43,7 @@ CachingRegistryClient.prototype._invalidatingRequest = function (uri, params, cb // thinking that it didn't work when it did. // Note that failure is an acceptable option here, since the only // result will be a stale cache for some helper commands. - client.log.verbose("request", "invalidating", invalidated, "on", method) + log.verbose("request", "invalidating", invalidated, "on", method) return rimraf(invalidated, function () { cb.apply(undefined, args) }) @@ -52,7 +53,7 @@ CachingRegistryClient.prototype._invalidatingRequest = function (uri, params, cb }) } -CachingRegistryClient.prototype.get = function get (uri, params, cb) { +function get (uri, params, cb) { assert(typeof uri === "string", "must pass registry URI to get") assert(params && typeof params === "object", "must pass params to get") assert(typeof cb === "function", "must pass callback to get") @@ -68,7 +69,10 @@ CachingRegistryClient.prototype.get = function get (uri, params, cb) { // If the GET is part of a write operation (PUT or DELETE), then // skip past the cache entirely, but still save the results. - if (uri.match(/\?write=true$/)) return get_.call(this, uri, cachePath, params, cb) + if (uri.match(/\?write=true$/)) { + log.verbose("get", "GET as part of write; not caching result") + return get_.call(this, uri, cachePath, params, cb) + } var client = this fs.stat(cachePath, function (er, stat) { @@ -170,6 +174,7 @@ function get_ (uri, cachePath, params, cb) { } function saveToCache (cachePath, data, saved) { + log.verbose("get", "saving", data.name, "to", cachePath) getCacheStat(function (er, st) { mkdirp(path.dirname(cachePath), function (er, made) { if (er) return saved() -- cgit v1.2.3