Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: log if npm deprecate does not match any version #7474

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/commands/deprecate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fetch = require('npm-registry-fetch')
const { otplease } = require('../utils/auth.js')
const npa = require('npm-package-arg')
const { log } = require('proc-log')
const semver = require('semver')
const getIdentity = require('../utils/get-identity.js')
const libaccess = require('libnpmaccess')
Expand Down Expand Up @@ -66,6 +67,8 @@ class Deprecate extends BaseCommand {
body: packument,
ignoreBody: true,
}))
} else {
log.warn('deprecate', 'No version found for', p.rawSpec)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/lib/commands/deprecate.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ t.test('deprecates all versions when no range is specified', async t => {
})

t.test('does nothing if version does not actually exist', async t => {
const { npm, joinedOutput } = await loadMockNpm(t, { config: { ...auth } })
const { npm, logs, joinedOutput } = await loadMockNpm(t, { config: { ...auth } })
const registry = new MockRegistry({
tap: t,
registry: npm.config.get('registry'),
Expand All @@ -168,4 +168,5 @@ t.test('does nothing if version does not actually exist', async t => {
await registry.package({ manifest, query: { write: true } })
await npm.exec('deprecate', ['foo@1.0.99', 'this should be ignored'])
t.match(joinedOutput(), '')
t.equal(logs.warn[0], 'deprecate No version found for 1.0.99')
})
Loading