Skip to content

Commit e864bd3

Browse files
committed
fix: do not update notify when installing npm@spec
PR-URL: #3345 Credit: @isaacs Close: #3345 Reviewed-by: @wraithgar
1 parent c4ef78b commit e864bd3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/utils/update-notifier.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { resolve } = require('path')
1414
const isGlobalNpmUpdate = npm => {
1515
return npm.flatOptions.global &&
1616
['install', 'update'].includes(npm.command) &&
17-
npm.argv.includes('npm')
17+
npm.argv.some(arg => /^npm(@|$)/.test(arg))
1818
}
1919

2020
// update check frequency

test/lib/utils/update-notifier.js

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ t.test('situations in which we do not notify', t => {
105105
t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests')
106106
})
107107

108+
t.test('do not suggest update if already updating with spec', async t => {
109+
t.equal(await updateNotifier({
110+
...npm,
111+
flatOptions: { ...flatOptions, global: true },
112+
command: 'install',
113+
argv: ['npm@latest'],
114+
}), null)
115+
t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests')
116+
})
117+
108118
t.test('do not update if same as latest', async t => {
109119
t.equal(await updateNotifier(npm), null)
110120
t.strictSame(MANIFEST_REQUEST, ['npm@latest'], 'requested latest version')

0 commit comments

Comments
 (0)