Skip to content

Commit

Permalink
Include prerelease versions when deprecating an entire package.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiegz committed Dec 17, 2020
1 parent e8c3796 commit 5db80d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/deprecate.js
Expand Up @@ -45,6 +45,7 @@ const deprecate = async ([pkg, msg]) => {
// npa makes the default spec "latest", but for deprecation
// "*" is the appropriate default.
const spec = p.rawSpec === '' ? '*' : p.fetchSpec
const options = spec === '*' ? {includePrerelease: true} : {}

if (semver.validRange(spec, true) === null)
throw new Error(`invalid version range: ${spec}`)
Expand All @@ -57,7 +58,7 @@ const deprecate = async ([pkg, msg]) => {
})

Object.keys(packument.versions)
.filter(v => semver.satisfies(v, spec))
.filter(v => semver.satisfies(v, spec, options))
.forEach(v => {
packument.versions[v].deprecated = msg
})
Expand Down
4 changes: 4 additions & 0 deletions test/lib/deprecate.js
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

0 comments on commit 5db80d7

Please sign in to comment.