Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
feat(clean): hide npm cache clean behind --force
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat authored and iarna committed May 25, 2017
1 parent ea1f220 commit 34f24c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/cache.js
Expand Up @@ -19,7 +19,7 @@ cache.usage = 'npm cache add <tarball file>' +
'\nnpm cache add <tarball url>' +
'\nnpm cache add <git url>' +
'\nnpm cache add <name>@<version>' +
'\nnpm cache clean [<pkg>[@<version>]]' +
'\nnpm cache clean' +
'\nnpm cache verify'

cache.completion = function (opts, cb) {
Expand Down Expand Up @@ -63,6 +63,9 @@ cache.clean = clean
function clean (args) {
if (!args) args = []
const cachePath = path.join(npm.cache, '_cacache')
if (!npm.config.get('force')) {
return BB.reject(new Error("As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.\n\nIf you're sure you want to delete the entire cache, rerun this command with --force."))
}
// TODO - remove specific packages or package versions
return rm(cachePath)
}
Expand Down

0 comments on commit 34f24c8

Please sign in to comment.