Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-03-07 02:51:32 +0400
committerisaacs <i@izs.me>2012-03-07 02:51:32 +0400
commit6cda571679632c35f468c805afeb7722d7c7b647 (patch)
tree90c985b7bd93ae1c29fa2a547663d18019de2c78
parent594bbbd20fbad5431776fd68e7e62abc1ffb0de4 (diff)
Fix: bundleDependencies being re-installed unnecessarily
-rw-r--r--lib/install.js11
-rw-r--r--test/packages/npm-test-bundled-git/minimatch-expected.json29
-rw-r--r--test/packages/npm-test-bundled-git/package.json4
-rw-r--r--test/packages/npm-test-bundled-git/test.sh9
4 files changed, 51 insertions, 2 deletions
diff --git a/lib/install.js b/lib/install.js
index 19d03d5a6..593999147 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -492,8 +492,7 @@ function targetResolver (where, context, deps) {
// check for a version installed higher in the tree.
// If installing from a shrinkwrap, it must match exactly.
if (context.family[what]) {
-
- if (wrap && wrap[what].version == context.family[what]) {
+ if (wrap && wrap[what].version === context.family[what]) {
log.verbose(what, "using existing (matches shrinkwrap)")
return cb(null, [])
}
@@ -727,6 +726,14 @@ function write (target, targetFolder, context, cb_) {
// before continuing to installing dependencies, check for a shrinkwrap.
readDependencies(context, targetFolder, {}, function (er, data, wrap) {
var deps = Object.keys(data.dependencies || {})
+
+ // don't install bundleDependencies
+ if (data.bundleDependencies) {
+ deps = deps.filter(function (d) {
+ return data.bundleDependencies.indexOf(d) === -1
+ })
+ }
+
var newcontext = { family: family
, ancestors: context.ancestors
, parent: target
diff --git a/test/packages/npm-test-bundled-git/minimatch-expected.json b/test/packages/npm-test-bundled-git/minimatch-expected.json
new file mode 100644
index 000000000..62b20d698
--- /dev/null
+++ b/test/packages/npm-test-bundled-git/minimatch-expected.json
@@ -0,0 +1,29 @@
+{
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "name": "minimatch",
+ "description": "a glob matcher in javascript",
+ "version": "0.2.1",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/minimatch.git"
+ },
+ "main": "minimatch.js",
+ "scripts": {
+ "test": "tap test"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {
+ "lru-cache": "~1.0.5"
+ },
+ "devDependencies": {
+ "tap": "~0.1.3"
+ },
+ "licenses" : [
+ {
+ "type" : "MIT",
+ "url" : "http://github.com/isaacs/minimatch/raw/master/LICENSE"
+ }
+ ]
+}
diff --git a/test/packages/npm-test-bundled-git/package.json b/test/packages/npm-test-bundled-git/package.json
new file mode 100644
index 000000000..75b7cd2d6
--- /dev/null
+++ b/test/packages/npm-test-bundled-git/package.json
@@ -0,0 +1,4 @@
+{"name":"npm-test-bundled-git"
+,"version":"1.2.5"
+,"dependencies":{"glob":"git://github.com/isaacs/node-glob.git#npm-test"}
+,"bundledDependencies":["glob"]}
diff --git a/test/packages/npm-test-bundled-git/test.sh b/test/packages/npm-test-bundled-git/test.sh
new file mode 100644
index 000000000..21da8e029
--- /dev/null
+++ b/test/packages/npm-test-bundled-git/test.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/bash
+
+d=$(diff node_modules/glob/node_modules/minimatch/package.json minimatch-expected.json)
+
+if [ "$d" != "" ]; then
+ echo "didn't get expected minimatch/package.json" >&2
+ echo "$d" >&2
+ exit 1
+fi