diff options
author | isaacs <i@izs.me> | 2013-12-11 21:51:23 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-12-11 21:51:23 +0400 |
commit | d8c907edc2019b75cff0f53467e34e0ffd7e5fba (patch) | |
tree | b9d0f9c1e5dcbe763d6f94632c4dbc13d26a508d | |
parent | 3c6bf558dde958be82d42c24eaa73fcf367f674c (diff) |
Revert "Avoid installing URL dependencies multiple times."
This reverts commit 644c2ff3e3d9c93764f7045762477f48864d64a7.
It's a good patch, and none of us caught the problem. However, this
introduces an arguably surprising new behavior, since `npm link -f` and
`npm install -f` will now reinstall ALL deps, no matter what.
-rw-r--r-- | lib/install.js | 8 | ||||
-rw-r--r-- | test/tap/url-dependencies.js | 89 | ||||
-rw-r--r-- | test/tap/url-dependencies/package.json | 8 |
3 files changed, 3 insertions, 102 deletions
diff --git a/lib/install.js b/lib/install.js index 0cf41a7ba..5b09f8b2f 100644 --- a/lib/install.js +++ b/lib/install.js @@ -604,12 +604,12 @@ function installMany (what, where, context, cb) { } function targetResolver (where, context, deps) { - var alreadyInstalledManually = context.explicit || npm.config.get("force") ? [] : null + var alreadyInstalledManually = context.explicit ? [] : null , nm = path.resolve(where, "node_modules") , parent = context.parent , wrap = context.wrap - if (!alreadyInstalledManually) fs.readdir(nm, function (er, inst) { + if (!context.explicit) fs.readdir(nm, function (er, inst) { if (er) return alreadyInstalledManually = [] // don't even mess with non-package looking things @@ -627,8 +627,7 @@ function targetResolver (where, context, deps) { // otherwise, make sure that it's a semver match with what we want. var bd = parent.bundleDependencies if (bd && bd.indexOf(d.name) !== -1 || - semver.satisfies(d.version, deps[d.name] || "*", true) || - deps[d.name] === d._resolved) { + semver.satisfies(d.version, deps[d.name] || "*", true)) { return cb(null, d.name) } @@ -640,7 +639,6 @@ function targetResolver (where, context, deps) { alreadyInstalledManually = inst }) }) - if(npm.config.get("force")) alreadyInstalledManually = [] var to = 0 return function resolver (what, cb) { diff --git a/test/tap/url-dependencies.js b/test/tap/url-dependencies.js deleted file mode 100644 index 53fbf766a..000000000 --- a/test/tap/url-dependencies.js +++ /dev/null @@ -1,89 +0,0 @@ -var test = require("tap").test -var rimraf = require("rimraf") - -var mr = require("npm-registry-mock") - -var spawn = require("child_process").spawn -var npm = require.resolve("../../bin/npm-cli.js") -var node = process.execPath -var pkg = "./url-dependencies" - -var mockRoutes = { - "get": { - "/underscore/-/underscore-1.3.1.tgz": [200] - } -} - -test("url-dependencies: download first time", function(t) { - rimraf.sync(__dirname + "/url-dependencies/node_modules") - - performInstall(function(output){ - if(!tarballWasFetched(output)){ - t.fail("Tarball was not fetched") - }else{ - t.pass("Tarball was fetched") - } - t.end() - }) -}) - -test("url-dependencies: do not download subsequent times", function(t) { - rimraf.sync(__dirname + "/url-dependencies/node_modules") - - performInstall(function(){ - performInstall(function(output){ - if(tarballWasFetched(output)){ - t.fail("Tarball was fetched second time around") - }else{ - t.pass("Tarball was not fetched") - } - t.end() - }) - }) -}) - -test("url-dependencies: still downloads multiple times when using --force", function(t) { - rimraf.sync(__dirname + "/url-dependencies/node_modules") - - performInstall(function(){ - performInstall(true, function(output){ - if(tarballWasFetched(output)){ - t.pass("Tarball was fetched when using --force") - }else{ - t.fail("Tarball was not fetched when using --force") - } - t.end() - }) - }) -}) - -function tarballWasFetched(output){ - return output.indexOf("http GET http://localhost:1337/underscore/-/underscore-1.3.1.tgz") > -1 -} - -function performInstall (force, cb) { - if(typeof force === "function") cb = force, force = false - - mr({port: 1337, mocks: mockRoutes}, function(s){ - var output = "" - , child = spawn(node, [npm, "install", force ? "--force" : ""], { - cwd: pkg, - env: { - npm_config_registry: "http://localhost:1337", - npm_config_cache_lock_stale: 1000, - npm_config_cache_lock_wait: 1000, - HOME: process.env.HOME, - Path: process.env.PATH, - PATH: process.env.PATH - } - }) - - child.stderr.on("data", function(data){ - output += data.toString() - }) - child.on("close", function () { - s.close() - cb(output) - }) - }) -} diff --git a/test/tap/url-dependencies/package.json b/test/tap/url-dependencies/package.json deleted file mode 100644 index 96ae3e247..000000000 --- a/test/tap/url-dependencies/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "author": "Steve Mason", - "name": "url-dependencies", - "version": "0.0.0", - "dependencies": { - "underscore": "http://localhost:1337/underscore/-/underscore-1.3.1.tgz" - } -} |