diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 510e351a931dc..661533a4a2333 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -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 diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index 0ede4ffc20c83..cd5c1bdad6aa3 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -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' }, ]