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

Commit

Permalink
Added a --force option to install so that remote resources are refetched
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass authored and isaacs committed Jan 27, 2011
1 parent 85983a3 commit bf41c86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/install.md
Expand Up @@ -78,6 +78,10 @@ You may combine multiple arguments, and even multiple types of arguments. For e

The `--tag` argument will apply to all of the specified install targets.

The `--force` argument will force npm to fetch remote resources even if a local copy exists on disk.

npm install sax --force

## CONFIGURATION

### root
Expand Down
7 changes: 6 additions & 1 deletion lib/cache.js
Expand Up @@ -109,6 +109,11 @@ function read (name, ver, cb) {
if (data) deprCheck(data)
return cb(er, data)
}
if (npm.config.get("force")) {
log.verbose(true, "force found, skipping cache")
return addNameVersion(name, ver, c)
}

if (name+"@"+ver in cacheSeen) {
return cb(null, cacheSeen[name+"@"+ver])
}
Expand Down Expand Up @@ -216,7 +221,7 @@ function addNameVersion (name, ver, cb) {
if (!data.dist || !data.dist.tarball) return cb(new Error(
"No dist.tarball in package data"))
//TODO: put the shasum in the data, and pass to addRemoteTarball
if (response.statusCode !== 304) return fetchit()
if (response.statusCode !== 304 || npm.config.get("force")) return fetchit()
// we got cached data, so let's see if we have a tarball.
fs.stat(path.join(npm.cache, name, ver, "package.tgz"), function (er, s) {
if (!er) return cb(null, data)
Expand Down

0 comments on commit bf41c86

Please sign in to comment.