diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js index 0a19be94e62a4..1af948a2db45a 100644 --- a/lib/utils/update-notifier.js +++ b/lib/utils/update-notifier.js @@ -14,7 +14,7 @@ const { resolve } = require('path') const isGlobalNpmUpdate = npm => { return npm.flatOptions.global && ['install', 'update'].includes(npm.command) && - npm.argv.includes('npm') + npm.argv.some(arg => /^npm(@|$)/.test(arg)) } // update check frequency diff --git a/test/lib/utils/update-notifier.js b/test/lib/utils/update-notifier.js index ad4d407728f93..9748a92a8ae7b 100644 --- a/test/lib/utils/update-notifier.js +++ b/test/lib/utils/update-notifier.js @@ -105,6 +105,16 @@ t.test('situations in which we do not notify', t => { t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests') }) + t.test('do not suggest update if already updating with spec', async t => { + t.equal(await updateNotifier({ + ...npm, + flatOptions: { ...flatOptions, global: true }, + command: 'install', + argv: ['npm@latest'], + }), null) + t.strictSame(MANIFEST_REQUEST, [], 'no requests for manifests') + }) + t.test('do not update if same as latest', async t => { t.equal(await updateNotifier(npm), null) t.strictSame(MANIFEST_REQUEST, ['npm@latest'], 'requested latest version')