Skip to content

Commit 25c4e21

Browse files
committed
1.1.1
- Fix CLI not parsing pre and rc versions
1 parent 2dd3b1c commit 25c4e21

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.1.1
4+
*2021-02-13*
5+
- Fixed command-line usage not parsing pre-release and release candidate versions.
6+
37
## 1.1.0
48
*2021-02-13*
59
- Added argument `type` to Node usage; valid values are `'data'` and `'resource'` for retrieving the respective pack format for certain versions.

cli.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#!/usr/bin/env node
2-
const VERSION = '1.1.0'
2+
const VERSION = '1.1.1'
33

44
const getPackFormat = require('./index.js')
55

66
const arg = n => process.argv[n + 1]
77

88
if (arg(1) && !arg(1).includes('h'))
9-
if (arg(1).includes('v'))
9+
if (/v/.test(arg(1)))
1010
console.log(`The current version of pack-format is ${VERSION}`)
11-
else if (arg(1).includes('d'))
11+
else if (/^-*d/.test(arg(1)))
1212
console.log(`Data pack format of ${arg(2)} is ${getPackFormat(arg(2), 'data')}`)
13-
else if (arg(1).includes('r'))
13+
else if (/^-*r/.test(arg(1)))
1414
console.log(`Resource pack format of ${arg(2)} is ${getPackFormat(arg(2), 'resource')}`)
1515
else
1616
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
1717
else {
18+
const indent = n => ' '.repeat(n * 4)
1819
const log = (arg, desc) => {
19-
console.log(`\n\tpack-format ${arg}`)
20-
for (text of desc) console.log('\t ' + text)
20+
console.log(`\n${indent(2)}pack-format ${arg}`)
21+
for (text of desc) console.log(indent(3) + text)
2122
}
22-
console.log(`\npack-format arguments:\n`)
23-
log('<version>', ['Retrieve the pack format of any Minecraft version.', ' Defaults to resource pack format when applicable.'])
23+
console.log(`\n${indent(1)}pack-format arguments:`)
24+
log('<version>', ['Retrieve the pack format of any Minecraft version.', indent(1) + 'Defaults to resource pack format when applicable.'])
2425
log('(--data|-d) <version>', ['Retrieve the data pack format in particular when applicable.'])
2526
log('(--resource|-r) <version>', ['Retrieve the resource pack format in particular when applicable.'])
2627
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pack-format",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Returns the pack_format of any Minecraft version, including snapshots",
55
"scripts": {
66
"test": "node test"

readme.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ pack-format is a Node.js tool for retrieving the `pack_format` of any Minecraft
88

99
## About
1010

11-
`pack_format` is a version number used in both resource packs and data packs for labeling compatible versions.
11+
`pack_format` is a version number used by Minecraft in both resource packs and data packs for labeling compatible versions.
1212
It was added in Minecraft version 1.6, and as such using this tool on any version prior to that will just return `undefined`.
1313

1414
## Install
1515

16-
Using npm, open your command prompt and type `npm install pack-format` to use for a Node.js project or `npm install -g pack-format` to use from the command line.
16+
pack-format is available on [npm](https://www.npmjs.com/package/pack-format).
17+
18+
To install pack-format, open your command prompt and type `npm install pack-format` to use for a Node.js project, or `npm install -g pack-format` to use from the command line.
1719

1820
## Usage
1921

@@ -22,16 +24,21 @@ Using npm, open your command prompt and type `npm install pack-format` to use fo
2224
```js
2325
const packFormat = require('pack-format')
2426
packFormat('1.14.4') // 4
25-
packFormat('1.16.2-pre1') // 5
27+
packFormat('1.16.2-pre1', 'resource') // 5
28+
packFormat('20w45a', 'data') // 6
2629
```
2730

2831
### Command line
2932

30-
`pack-format <version>`
33+
`pack-format [--data|--resource] <version>`
3134

3235
```sh
3336
> pack-format 1.14.4
3437
Pack format of 1.14.4 is 4
35-
> pack-format 1.16.2-pre1
36-
Pack format of 1.16.2-pre1 is 5
38+
39+
> pack-format --resource 1.16.2-pre1
40+
Resource pack format of 1.16.2-pre1 is 5
41+
42+
> pack-format --data 20w30a
43+
Data pack format of 20w45a is 6
3744
```

0 commit comments

Comments
 (0)