Skip to content

Commit 6788fcf

Browse files
committed
Fix --list use on recent versions
1 parent e19f197 commit 6788fcf

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Changed CLI parsing to support decimal pack formats.
55
- Updated resource pack format to `65.2`.
66
- Updated data pack format to `83.0`.
7+
- Fixed use of `--list` on recent pack formats.
78

89
## 1.4.2
910
*2025-06-27*

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ else if (args.list) {
9191
const snaps = [vers.snapshots.min, vers.snapshots.max].filter(x => x)
9292
const relText = ['', rels[0], rels.join('–')][[...new Set(rels)].length]
9393
const snapsText = ['', snaps[0], snaps.join('–')][[...new Set(snaps)].length]
94-
const fullText = relText ? `${relText} (${snapsText})` : `${snapsText}`
94+
const fullText = relText && snapsText ? `${relText} (${snapsText})` : (relText ?? snapsText)
9595

96-
if (snapsText)
96+
if (fullText)
9797
console.log(`A ${type} pack format of ${ver} is used for ${fullText}`)
9898
else
9999
console.log(`A ${type} pack format of ${ver} is not used`)

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ function getVersions(format: number, type: PackType = 'resource'): VersionsResul
270270
const startReleases = Object.entries(START_RELEASES)
271271
const relIndex = startReleases.findIndex(([, data]) => data[type] === format)
272272
if (relIndex >= 0) {
273-
const lastWithFormat = startReleases.find(([, obj]) => (obj[type] ?? 0) > format) ?? []
273+
const lastWithFormat = startReleases.find(([, obj]) => (obj[type] ?? 0) > format)?.[0]
274274
const minRelease = startReleases[relIndex][0].replace('.x', '') as VersionName
275-
const maxRelease = getVersionBelow(lastWithFormat[0] as VersionName, minRelease)
275+
const maxRelease = lastWithFormat ? getVersionBelow(lastWithFormat as VersionName, minRelease) : LATEST_REL
276276
output.releases.min = minRelease as VersionName
277-
output.releases.max = maxRelease
277+
output.releases.max = maxRelease as VersionName
278278
}
279279

280280
// Min and max snapshots

test/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ testVersions([7, 'resource'], { releases: { min: '1.17', max: '1.17.1' }, snapsh
6565
testVersions([10, 'data'], { releases: { min: '1.19', max: '1.19.3' }, snapshots: { min: '22w11a', max: '23w02a' } })
6666
testVersions([11, 'resource'], { releases: { min: null, max: null }, snapshots: { min: '22w42a', max: '22w44a' } })
6767
testVersions([15, 'data'], { releases: { min: '1.20', max: '1.20.1' }, snapshots: { min: '23w18a', max: '23w30a' } })
68+
testVersions([64, 'resource'], { releases: { min: '1.21.7', max: '1.21.8' }, snapshots: { min: null, max: null } })
6869

6970
console.log(`\nRan ${total} tests | ${passed} passed | ${failed} failed`)

0 commit comments

Comments
 (0)