Skip to content

Commit

Permalink
fix(publish): disregard deprecated versions when calculating highest …
Browse files Browse the repository at this point in the history
…version
  • Loading branch information
wraithgar committed Jan 17, 2025
1 parent 7f72944 commit 8a911ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ class Publish extends BaseCommand {
const ordered = Object.keys(packument?.versions)
.flatMap(v => {
const s = new semver.SemVer(v)
return s.prerelease.length > 0 ? [] : s
if ((s.prerelease.length > 0) || packument.versions[v].deprecated) {
return []
}
return s
})
.sort((a, b) => b.compare(a))
return ordered.length >= 1 ? ordered[0].version : null
Expand Down
1 change: 1 addition & 0 deletions test/lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ t.test('semver highest dist tag', async t => {
// this needs more than one item in it to cover the sort logic
{ version: '50.0.0' },
{ version: '100.0.0' },
{ version: '102.0.0', deprecated: 'oops' },
{ version: '105.0.0-pre' },
]

Expand Down

0 comments on commit 8a911ff

Please sign in to comment.