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>2010-11-25 03:52:08 +0300
committerisaacs <i@izs.me>2010-11-25 03:52:20 +0300
commitdf152ab031f2489b7f1a45aa2c3e525371ebf0b7 (patch)
tree2bc809fda7a7edf8114a14cf273c36d585a5ad1a
parente427526d12df1dade467858b9bf98867f336e2ca (diff)
Add the 'must-install' config, and use it in bundling
-rw-r--r--doc/config.md8
-rw-r--r--lib/bundle.js5
-rw-r--r--lib/install.js9
-rw-r--r--lib/utils/default-config.js1
-rw-r--r--man1/config.17
5 files changed, 27 insertions, 3 deletions
diff --git a/doc/config.md b/doc/config.md
index 29772b1f0..b199deb5c 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -319,3 +319,11 @@ For example: `listopts = remote`
`npm ls`
The output here will always filter by remote
+
+### must-install
+
+Default: true
+
+Set to false to not install over packages that already exist. By
+default, `npm install foo` will fetch and install the latest version of
+`foo`, even if it matches a version already installed.
diff --git a/lib/bundle.js b/lib/bundle.js
index 5257714c3..752c01523 100644
--- a/lib/bundle.js
+++ b/lib/bundle.js
@@ -27,6 +27,7 @@ function bundle (args, cb_) {
var c = { root : location
, binroot : null
, manroot : null
+ , "must-install" : false
}
conf.unshift(c)
@@ -74,5 +75,7 @@ function install (data, location, cb) {
return v ? d + "@" + v : d
})
log.verbose(deps, "bundle deps")
- npm.commands.install(deps, cb)
+ npm.commands.install(deps, log.er(cb, "Some dependencies failed to bundle\n"
+ + "Bundle them separately with\n"
+ + " npm bundle install <pkg>"))
}
diff --git a/lib/install.js b/lib/install.js
index e7def3047..b8c15e8bc 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -39,6 +39,7 @@ var registry = require("./utils/registry")
, asyncMap = require("./utils/async-map")
function install (pkglist, cb) {
+ log.verbose(pkglist, "install")
if (pkglist.length === 0) pkglist = ["."]
// it's helpful to know what we have already
if (!installedPackages) return readInstalled([], function (er, data) {
@@ -48,7 +49,7 @@ function install (pkglist, cb) {
})
log.verbose(pkglist, "install pkglist")
- var mustInstall = pkglist.slice(0)
+ var mustInstall = npm.config.get("must-install") ? pkglist.slice(0) : []
// three lists: "pkglist", "next", and "reg"
// asyncMap over the "left" list: for each "it"
@@ -250,7 +251,11 @@ function buildAll (installed, cb) {
}, function (er) {
if (er) return cb(er)
log.verbose(list.join("\n"), "unpacked, building")
- npm.commands.build(buildList, cb)
+ if (buildList.length) npm.commands.build(buildList, cb)
+ else {
+ log.info("Nothing to do", "install")
+ cb()
+ }
})
}
function rollbackFailure (installList, cb) { return function (er) {
diff --git a/lib/utils/default-config.js b/lib/utils/default-config.js
index ab165bc0b..519c626a8 100644
--- a/lib/utils/default-config.js
+++ b/lib/utils/default-config.js
@@ -37,6 +37,7 @@ module.exports =
, force : false
, prune : undefined // if set to boolean false, then that means "never"
, listopts: ""
+ , "must-install" : true
//
// TODO: Fix when node's SSL client can upload properly.
// , registry : hasSSL ? "https://registry.npmjs.org/"
diff --git a/man1/config.1 b/man1/config.1
index a65f96e61..9796c3772 100644
--- a/man1/config.1
+++ b/man1/config.1
@@ -409,3 +409,10 @@ For example: \fBlistopts = remote\fR
.
.P
The output here will always filter by remote
+.
+.SS "must\-install"
+Default: true
+.
+.P
+Set to false to not install over packages that already exist\. By
+default, \fBnpm install foo\fR will fetch and install the latest version of \fBfoo\fR, even if it matches a version already installed\.