Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a --force option to install so that remote resources are refetched

  • Loading branch information...
commit bf41c86e231a3fd200133831f732bad61e728b92 1 parent 85983a3
@davglass davglass authored isaacs committed
Showing with 10 additions and 1 deletion.
  1. +4 −0 doc/install.md
  2. +6 −1 lib/cache.js
View
4 doc/install.md
@@ -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
View
7 lib/cache.js
@@ -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])
}
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.