node/deps/npm/node_modules/cacache/lib/content/rm.js
npm-cli+bot@github.com 6375b13de8
deps: upgrade npm to 8.11.0
PR-URL: https://github.com/nodejs/node/pull/43210
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2022-05-27 11:13:35 -04:00

21 lines
493 B
JavaScript

'use strict'
const util = require('util')
const contentPath = require('./path')
const { hasContent } = require('./read')
const rimraf = util.promisify(require('rimraf'))
module.exports = rm
async function rm (cache, integrity) {
const content = await hasContent(cache, integrity)
// ~pretty~ sure we can't end up with a content lacking sri, but be safe
if (content && content.sri) {
await rimraf(contentPath(cache, content.sri))
return true
} else {
return false
}
}