rm.js 676 B

12345678910111213141516171819202122232425262728293031
  1. 'use strict'
  2. const util = require('util')
  3. const index = require('./lib/entry-index')
  4. const memo = require('./lib/memoization')
  5. const path = require('path')
  6. const rimraf = util.promisify(require('rimraf'))
  7. const rmContent = require('./lib/content/rm')
  8. module.exports = entry
  9. module.exports.entry = entry
  10. function entry (cache, key, opts) {
  11. memo.clearMemoized()
  12. return index.delete(cache, key, opts)
  13. }
  14. module.exports.content = content
  15. function content (cache, integrity) {
  16. memo.clearMemoized()
  17. return rmContent(cache, integrity)
  18. }
  19. module.exports.all = all
  20. function all (cache) {
  21. memo.clearMemoized()
  22. return rimraf(path.join(cache, '*(content-*|index-*)'))
  23. }