Skip to content

Commit ca1a68d

Browse files
authored
fix: log if npm deprecate does not match any version (#7474)
If the package specification does not match any existing version, a warning message is added to the log. ## References Ref #7472 Closes #7180
1 parent e39d422 commit ca1a68d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/commands/deprecate.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fetch = require('npm-registry-fetch')
22
const { otplease } = require('../utils/auth.js')
33
const npa = require('npm-package-arg')
4+
const { log } = require('proc-log')
45
const semver = require('semver')
56
const getIdentity = require('../utils/get-identity.js')
67
const libaccess = require('libnpmaccess')
@@ -66,6 +67,8 @@ class Deprecate extends BaseCommand {
6667
body: packument,
6768
ignoreBody: true,
6869
}))
70+
} else {
71+
log.warn('deprecate', 'No version found for', p.rawSpec)
6972
}
7073
}
7174
}

test/lib/commands/deprecate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ t.test('deprecates all versions when no range is specified', async t => {
155155
})
156156

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

0 commit comments

Comments
 (0)