rm.js 499 B

12345678910111213141516171819
  1. 'use strict'
  2. const util = require('util')
  3. const contentPath = require('./path')
  4. const { hasContent } = require('./read')
  5. const rimraf = util.promisify(require('rimraf'))
  6. module.exports = rm
  7. function rm (cache, integrity) {
  8. return hasContent(cache, integrity).then((content) => {
  9. // ~pretty~ sure we can't end up with a content lacking sri, but be safe
  10. if (content && content.sri)
  11. return rimraf(contentPath(cache, content.sri)).then(() => true)
  12. else
  13. return false
  14. })
  15. }