diff options
Diffstat (limited to 'node_modules/cacache/lib/content/rm.js')
-rw-r--r-- | node_modules/cacache/lib/content/rm.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/cacache/lib/content/rm.js b/node_modules/cacache/lib/content/rm.js new file mode 100644 index 0000000..5061236 --- /dev/null +++ b/node_modules/cacache/lib/content/rm.js @@ -0,0 +1,20 @@ +'use strict' + +const util = require('util') + +const contentPath = require('./path') +const { hasContent } = require('./read') +const rimraf = util.promisify(require('rimraf')) + +module.exports = rm + +function rm (cache, integrity) { + return hasContent(cache, integrity).then((content) => { + // ~pretty~ sure we can't end up with a content lacking sri, but be safe + if (content && content.sri) { + return rimraf(contentPath(cache, content.sri)).then(() => true) + } else { + return false + } + }) +} |