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:
authorForrest L Norvell <forrest@npmjs.com>2015-03-05 22:28:50 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-03-05 22:44:57 +0300
commit6de1e91116a5105dfa75126532b9083d8672e034 (patch)
treec02c94483549a838c3bc73f0c7f71c4b385f0b53
parentc9bd58dd637b9c41441023584a13e3818d5db336 (diff)
update: only update when current !== wanted
Fixes #6441.
-rw-r--r--lib/update.js20
-rw-r--r--test/tap/update-examples.js10
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/update.js b/lib/update.js
index 06d199cc0..3e9438e92 100644
--- a/lib/update.js
+++ b/lib/update.js
@@ -22,10 +22,26 @@ update.completion = npm.commands.outdated.completion
function update (args, cb) {
npm.commands.outdated(args, true, function (er, outdated) {
- log.info("outdated", "updating", outdated)
if (er) return cb(er)
- asyncMap(outdated, function (ww, cb) {
+ var wanted = outdated.filter(function (ww) {
+ var dep = ww[1]
+ var current = ww[2]
+ var wanted = ww[3]
+ var latest = ww[4]
+ if (current === wanted && wanted !== latest) {
+ log.verbose(
+ 'outdated',
+ 'not updating', dep,
+ "because it's currently at the maximum version that matches its specified semver range"
+ )
+ }
+ return current !== wanted
+ })
+ if (wanted.length === 0) return cb()
+
+ log.info('outdated', 'updating', wanted)
+ asyncMap(wanted, function (ww, cb) {
// [[ dir, dep, has, want, req ]]
var where = ww[0]
, dep = ww[1]
diff --git a/test/tap/update-examples.js b/test/tap/update-examples.js
index 2349e2532..633713d9d 100644
--- a/test/tap/update-examples.js
+++ b/test/tap/update-examples.js
@@ -158,6 +158,16 @@ test('update tilde dependency to latest', function (t) {
})
})
+test('hold tilde dependency at wanted (#6441)', function (t) {
+ resetPackage({ wanted: '~1.1.2', installed: '1.1.2' })
+
+ npm.commands.update([], function (err) {
+ t.ifError(err)
+ t.notOk(installAskedFor, 'should not want to install anything')
+ t.end()
+ })
+})
+
test('update old caret dependency with no newer', function (t) {
resetPackage({ wanted: '^0.2.0', installed: '^0.2.0' })