From 926c1d3c54f2de0b267b7c50d103fe2ed5036ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Sun, 23 Apr 2017 01:05:26 -0700 Subject: [PATCH] fix(deps): bump cacache and use its size feature --- cache.js | 15 +++------------ package.json | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cache.js b/cache.js index adaa34b..84f3169 100644 --- a/cache.js +++ b/cache.js @@ -2,7 +2,6 @@ const cacache = require('cacache') const fetch = require('node-fetch') -const fs = require('fs') const pipe = require('mississippi').pipe const ssri = require('ssri') const through = require('mississippi').through @@ -57,15 +56,7 @@ module.exports = class Cache { status: 200 }) } - return new this.Promise((resolve, reject) => { - fs.stat(info.path, (err, stat) => { - if (err) { - return reject(err) - } else { - return resolve(stat) - } - }) - }).then(stat => { + return Promise.resolve().then(() => { const cachePath = this._path let disturbed = false // avoid opening cache file handles until a user actually tries to @@ -75,7 +66,7 @@ module.exports = class Cache { cb(null, chunk, enc) } else { disturbed = true - if (stat.size > MAX_MEM_SIZE) { + if (info.size > MAX_MEM_SIZE) { pipe( cacache.get.stream.byDigest(cachePath, info.integrity), body, @@ -99,7 +90,7 @@ module.exports = class Cache { url: req.url, headers: resHeaders, status: 200, - size: stat.size + size: info.size }) }).catch(err => { if (err.code === 'ENOENT') { diff --git a/package.json b/package.json index ea063ff..2502547 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ ], "dependencies": { "agentkeepalive": "^3.1.0", - "cacache": "^7.0.5", + "cacache": "^8.0.0", "http-cache-semantics": "^3.7.3", "http-proxy-agent": "^1.0.0", "https-proxy-agent": "^1.0.0",