diff options
author | David Emmerson <david.emmerson@gmail.com> | 2016-05-30 00:02:43 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2016-08-12 00:28:01 +0300 |
commit | 1619871ac0cc8839dc9962c78e736095976c1eb4 (patch) | |
tree | 997b53707435da84774afc8d7ba533124aa272e7 | |
parent | 0f7e3197bcec7a328b603efdffd3681bbc40f585 (diff) |
update-linked: Only warn about symlink update if version number differs
The update-linked action outputs a warning that it needs to update the
linked package, but can't, There is no need for the package to be updated if
it is already at the correct version. This change does a check before
logging the warning.
PR-URL: https://github.com/npm/npm/pull/12893
Credit: @DaveEmmerson
Reviewed-By: @iarna
-rw-r--r-- | lib/install/action/update-linked.js | 6 | ||||
-rw-r--r-- | test/tap/update-symlink.js | 29 |
2 files changed, 32 insertions, 3 deletions
diff --git a/lib/install/action/update-linked.js b/lib/install/action/update-linked.js index 46c4cdfad..b37f477e1 100644 --- a/lib/install/action/update-linked.js +++ b/lib/install/action/update-linked.js @@ -2,7 +2,9 @@ var path = require('path') module.exports = function (top, buildpath, pkg, log, next) { - log.warn('update-linked', path.relative(top, pkg.path), 'needs updating to', pkg.package.version, - 'from', pkg.oldPkg.package.version, "but we can't, as it's a symlink") + if (pkg.package.version !== pkg.oldPkg.package.version) { + log.warn('update-linked', path.relative(top, pkg.path), 'needs updating to', pkg.package.version, + 'from', pkg.oldPkg.package.version, "but we can't, as it's a symlink") + } next() } diff --git a/test/tap/update-symlink.js b/test/tap/update-symlink.js index de7ca7bfb..1fb07b8a7 100644 --- a/test/tap/update-symlink.js +++ b/test/tap/update-symlink.js @@ -73,9 +73,36 @@ test('setup', function (t) { test('when update is called linked packages should be excluded', function (t) { common.npm(['update'], OPTS, function (err, c, out, stderr) { t.ifError(err) + t.equal(c, 0) t.has(out, /async@0.2.10/, 'updated ok') t.doesNotHave(stderr, /ERR!/, 'no errors in stderr') - server.done() + t.end() + }) +}) + +test('when install is called and the package already exists as a link, outputs a warning if the requested version is not the same as the linked one', function (t) { + common.npm(['install', 'underscore'], OPTS, function (err, c, out, stderr) { + t.ifError(err) + t.equal(c, 0) + + t.comment(out.trim()) + t.comment(stderr.trim()) + t.doesNotHave(out, /underscore/, 'linked package not updated') + t.has(stderr, /underscore/, 'warning output relating to linked package') + t.doesNotHave(stderr, /ERR!/, 'no errors in stderr') + t.end() + }) +}) + +test('when install is called and the package already exists as a link, does not warn if the requested version is same as the linked one', function (t) { + common.npm(['install', 'underscore@1.3.1'], OPTS, function (err, c, out, stderr) { + t.ifError(err) + t.equal(c, 0) + t.comment(out.trim()) + t.comment(stderr.trim()) + t.doesNotHave(out, /underscore/, 'linked package not updated') + t.doesNotHave(stderr, /underscore/, 'no warning or error relating to linked package') + t.doesNotHave(stderr, /ERR!/, 'no errors in stderr') t.end() }) }) |