Skip to content

Commit 6ccbfd4

Browse files
committed
Use null instead of '' to denote no version
1 parent 21700ca commit 6ccbfd4

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Next
44
- Added basic message when no arguments are given.
5+
- Changed output of `getVersions` to return `null` instead of `''` when a version is not present.
56
- Changed output of `getVersions` to replace '`.x`' with the actual game version.
67
- Changed CLI output of `--list` to present the versions in prose instead of JSON.
78
- Changed help message.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ function getPackFormats(version: string): Record<PackType, FormatResult> {
182182
* @returns an object containing minimum and maximum applicable release and snapshot versions
183183
*/
184184
function getVersions(format: number, type: PackType = 'resource'): VersionsResult {
185-
let output: VersionsResult = {
186-
'releases': { 'min': '', 'max': '' },
187-
'snapshots': { 'min': '', 'max': '' },
185+
const output: VersionsResult = {
186+
'releases': { 'min': null, 'max': null },
187+
'snapshots': { 'min': null, 'max': null },
188188
}
189189
if (!format || format > LATEST[type] || (type === 'data' && format < 4)) return output
190190

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export type PackMap = Record<PackType, FormatResult>
77
export type FormatResult = number | null | undefined
88

99
export interface VersionsResult {
10-
releases: { min: VersionName | '', max: VersionName | '' },
11-
snapshots: { min: SnapshotName | '', max: SnapshotName | '' },
10+
releases: { min: VersionName | null, max: VersionName | null },
11+
snapshots: { min: SnapshotName | null, max: SnapshotName | null },
1212
}

test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ function testPackFormats() {
4747

4848
testPackFormats()
4949

50-
testVersions([3, 'data'], { releases: { min: '', max: '' }, snapshots: { min: '', max: '' } })
51-
testVersions([10, 'resource'], { releases: { min: '', max: '' }, snapshots: { min: '', max: '' } })
52-
testVersions([6, 'resource'], { releases: { min: '1.16.2', max: '1.16.5' }, snapshots: { min: '', max: '' } })
50+
testVersions([3, 'data'], { releases: { min: null, max: null }, snapshots: { min: null, max: null } })
51+
testVersions([10, 'resource'], { releases: { min: null, max: null }, snapshots: { min: null, max: null } })
52+
testVersions([6, 'resource'], { releases: { min: '1.16.2', max: '1.16.5' }, snapshots: { min: null, max: null } })
5353
testVersions([6, 'data'], { releases: { min: '1.16.2', max: '1.16.5' }, snapshots: { min: '20w45a', max: '20w45a' } })
5454
testVersions([7, 'resource'], { releases: { min: '1.17', max: '1.17.1' }, snapshots: { min: '20w45a', max: '21w38a' } })
5555
testVersions([10, 'data'], { releases: { min: '1.19', max: '1.19.3' }, snapshots: { min: '22w11a', max: '23w02a' } })
56-
testVersions([11, 'resource'], { releases: { min: '', max: '' }, snapshots: { min: '22w42a', max: '22w44a' } })
56+
testVersions([11, 'resource'], { releases: { min: null, max: null }, snapshots: { min: '22w42a', max: '22w44a' } })
5757
testVersions([15, 'data'], { releases: { min: '1.20', max: '1.20.1' }, snapshots: { min: '23w18a', max: '23w30a' } })
5858

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

0 commit comments

Comments
 (0)