Skip to content

Commit d2e298f

Browse files
committed
fix(deprecate): add undeprecate support
Setting a deprecation of an empty string is the way to un-deprecate a package, this was accidentally broken in a past refactoring, and is now re-added with a test to ensure it is allowed. PR-URL: #3484 Credit: @wraithgar Close: #3484 Reviewed-by: @isaacs
1 parent 0dd0341 commit d2e298f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/deprecate.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class Deprecate extends BaseCommand {
4949
}
5050

5151
async deprecate ([pkg, msg]) {
52-
if (!pkg || !msg)
52+
// msg == null becase '' is a valid value, it indicates undeprecate
53+
if (!pkg || msg == null)
5354
throw this.usageError()
5455

5556
// fetch the data and make sure it exists.

test/lib/deprecate.js

+15
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ t.test('invalid semver range', t => {
7878
})
7979
})
8080

81+
t.test('undeprecate', t => {
82+
deprecate.exec(['foo', ''], (err) => {
83+
if (err)
84+
throw err
85+
t.match(npmFetchBody, {
86+
versions: {
87+
'1.0.0': { deprecated: '' },
88+
'1.0.1': { deprecated: '' },
89+
'1.0.1-pre': { deprecated: '' },
90+
},
91+
}, 'undeprecates everything')
92+
t.end()
93+
})
94+
})
95+
8196
t.test('deprecates given range', t => {
8297
t.teardown(() => {
8398
npmFetchBody = null

0 commit comments

Comments
 (0)