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

Include prerelease versions when deprecating an entire package. #2366

Merged
merged 1 commit into from
Dec 18, 2020
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
15 changes: 12 additions & 3 deletions docs/content/commands/npm-deprecate.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Deprecate a version of a package
### Synopsis

```bash
npm deprecate <pkg>[@<version>] <message>
npm deprecate <pkg>[@<version range>] <message>
```

### Description
Expand All @@ -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 [email protected] "1.x is no longer supported"
```

In this case, a version `[email protected]` 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
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
4 changes: 4 additions & 0 deletions test/lib/deprecate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npmFetch.json = async (uri, opts) => {
versions: {
'1.0.0': {},
'1.0.1': {},
'1.0.1-pre': {},
},
}
}
Expand Down Expand Up @@ -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',
},
},
})

Expand Down