Skip to content

Commit 8a911ff

Browse files
committed
fix(publish): disregard deprecated versions when calculating highest version
1 parent 7f72944 commit 8a911ff

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/commands/publish.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,10 @@ class Publish extends BaseCommand {
217217
const ordered = Object.keys(packument?.versions)
218218
.flatMap(v => {
219219
const s = new semver.SemVer(v)
220-
return s.prerelease.length > 0 ? [] : s
220+
if ((s.prerelease.length > 0) || packument.versions[v].deprecated) {
221+
return []
222+
}
223+
return s
221224
})
222225
.sort((a, b) => b.compare(a))
223226
return ordered.length >= 1 ? ordered[0].version : null

test/lib/commands/publish.js

+1
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ t.test('semver highest dist tag', async t => {
876876
// this needs more than one item in it to cover the sort logic
877877
{ version: '50.0.0' },
878878
{ version: '100.0.0' },
879+
{ version: '102.0.0', deprecated: 'oops' },
879880
{ version: '105.0.0-pre' },
880881
]
881882

0 commit comments

Comments
 (0)