diff --git a/docs/content/commands/npm-deprecate.md b/docs/content/commands/npm-deprecate.md index d0440efe89021..139441856bb06 100644 --- a/docs/content/commands/npm-deprecate.md +++ b/docs/content/commands/npm-deprecate.md @@ -7,7 +7,7 @@ description: Deprecate a version of a package ### Synopsis ```bash -npm deprecate [@] +npm deprecate [@] ``` ### Description @@ -22,8 +22,17 @@ versions, so you can do something like this: npm deprecate my-thing@"< 0.2.3" "critical bug fixed in v0.2.3" ``` -Note that you must be the package owner to deprecate something. See the -`owner` and `adduser` help topics. +SemVer ranges passed to this command are interpreted such that they *do* +include prerelease versions. For example: + +```bash +npm deprecate my-thing@1.x "1.x is no longer supported" +``` + +In this case, a version `my-thing@1.0.0-beta.0` will also be deprecated. + +You must be the package owner to deprecate something. See the `owner` and +`adduser` help topics. To un-deprecate a package, specify an empty string (`""`) for the `message` argument. Note that you must use double quotes with no space between them to diff --git a/lib/deprecate.js b/lib/deprecate.js index 1a46148e8405e..e049986452b79 100644 --- a/lib/deprecate.js +++ b/lib/deprecate.js @@ -58,7 +58,7 @@ const deprecate = async ([pkg, msg]) => { }) Object.keys(packument.versions) - .filter(v => semver.satisfies(v, spec)) + .filter(v => semver.satisfies(v, spec, { includePrerelease: true })) .forEach(v => { packument.versions[v].deprecated = msg }) diff --git a/test/lib/deprecate.js b/test/lib/deprecate.js index 3908254ed0d63..229cb9137a42c 100644 --- a/test/lib/deprecate.js +++ b/test/lib/deprecate.js @@ -13,6 +13,7 @@ npmFetch.json = async (uri, opts) => { versions: { '1.0.0': {}, '1.0.1': {}, + '1.0.1-pre': {}, }, } } @@ -126,6 +127,9 @@ test('deprecates all versions when no range is specified', t => { '1.0.1': { deprecated: 'this version is deprecated', }, + '1.0.1-pre': { + deprecated: 'this version is deprecated', + }, }, })