You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
472 B

4 years ago
  1. 'use strict'
  2. const BB = require('bluebird')
  3. const contentPath = require('./path')
  4. const hasContent = require('./read').hasContent
  5. const rimraf = BB.promisify(require('rimraf'))
  6. module.exports = rm
  7. function rm (cache, integrity) {
  8. return hasContent(cache, integrity).then(content => {
  9. if (content) {
  10. const sri = content.sri
  11. if (sri) {
  12. return rimraf(contentPath(cache, sri)).then(() => true)
  13. }
  14. } else {
  15. return false
  16. }
  17. })
  18. }