Skip to content

Commit 937d57f

Browse files
committed
1.0.5
- Add flag aliases `v` and `h` - Fix a CLI crash
1 parent 6e6a6e4 commit 937d57f

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed

changelog.md

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

3+
## 1.0.5
4+
*2021-02-09*
5+
- Added flag aliases `h` and `v` for `--help` and `--version` respectively.
6+
- Fixed a crash occurring when retrieving a pack format via the command-line.
7+
38
## 1.0.4
49
*2021-02-09*
510
- Fixed command-line usage not working.

cli.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
#!usr/bin/env node
2-
const VERSION = '1.0.4'
1+
#!/usr/bin/env node
2+
const VERSION = '1.0.5'
33

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

6-
function cli() {
6+
const arg = n => process.argv[n + 1]
77

8-
const arg = n => process.argv[n + 1]
9-
10-
if (arg(1) && !arg(1).includes('-h'))
11-
if (arg(1).includes('-v'))
12-
console.log(`The current version of pack-format is ${VERSION}`)
13-
else
14-
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
8+
if (arg(1) && !arg(1).includes('h'))
9+
if (arg(1).includes('v'))
10+
console.log(`The current version of pack-format is ${VERSION}`)
1511
else
16-
console.log('Type `pack-format <version>` to retrieve the pack format of any Minecraft version.')
17-
18-
}
12+
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
13+
else
14+
console.log('Type `pack-format <version>` to retrieve the pack format of any Minecraft version.')
1915

20-
module.exports = cli

index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env node
22

3-
const cli = require('./cli.js')
4-
53
class Snapshot {
64
constructor(version) { this.version = version }
75
getYear() { return parseInt(this.version.replace(/^(\d\d).+$/, '$1')) }
@@ -63,8 +61,4 @@ function getPackFormat(version) {
6361
}
6462
}
6563

66-
if (require.main === module) {
67-
cli()
68-
}
69-
7064
module.exports = getPackFormat

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pack-format",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Returns the pack_format of any Minecraft version, including snapshots",
55
"scripts": {
66
"test": "node test"
@@ -13,7 +13,7 @@
1313
],
1414
"main": "index.js",
1515
"bin": {
16-
"pack-format": "index.js"
16+
"pack-format": "cli.js"
1717
},
1818
"repository": {
1919
"type": "git",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ packFormat('1.16.2-pre1') // 5
2929

3030
`pack-format <version>`
3131

32-
```cmd
32+
```sh
3333
> pack-format 1.14.4
3434
Pack format of 1.14.4 is 4
3535
> pack-format 1.16.2-pre1

0 commit comments

Comments
 (0)