Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-06-30 19:26:57 +0300
committerGar <gar+gh@danger.computer>2021-06-30 19:40:38 +0300
commitd2e298f3cbab278071480f94ff7d916d42cbf43b (patch)
tree9b4a95e12ba37cf4d2a2fe36833948f7d44ca8a7
parent0dd0341ac9a65a2df8fc262ad9a56b7351f99d66 (diff)
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: https://github.com/npm/cli/pull/3484 Credit: @wraithgar Close: #3484 Reviewed-by: @isaacs
-rw-r--r--lib/deprecate.js3
-rw-r--r--test/lib/deprecate.js15
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/deprecate.js b/lib/deprecate.js
index ece55e1f4..156bbf875 100644
--- a/lib/deprecate.js
+++ b/lib/deprecate.js
@@ -49,7 +49,8 @@ class Deprecate extends BaseCommand {
}
async deprecate ([pkg, msg]) {
- if (!pkg || !msg)
+ // msg == null becase '' is a valid value, it indicates undeprecate
+ if (!pkg || msg == null)
throw this.usageError()
// fetch the data and make sure it exists.
diff --git a/test/lib/deprecate.js b/test/lib/deprecate.js
index c358fde24..a69ef6c77 100644
--- a/test/lib/deprecate.js
+++ b/test/lib/deprecate.js
@@ -78,6 +78,21 @@ t.test('invalid semver range', t => {
})
})
+t.test('undeprecate', t => {
+ deprecate.exec(['foo', ''], (err) => {
+ if (err)
+ throw err
+ t.match(npmFetchBody, {
+ versions: {
+ '1.0.0': { deprecated: '' },
+ '1.0.1': { deprecated: '' },
+ '1.0.1-pre': { deprecated: '' },
+ },
+ }, 'undeprecates everything')
+ t.end()
+ })
+})
+
t.test('deprecates given range', t => {
t.teardown(() => {
npmFetchBody = null