Skip to content

Commit

Permalink
1.0.4
Browse files Browse the repository at this point in the history
- Fix CLI usage
  • Loading branch information
Nixinova committed Feb 9, 2021
1 parent aba4016 commit 6e6a6e4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.4
*2021-02-09*
- Fixed command-line usage not working.

## 1.0.3
*2021-02-09*
- Added a help message, given by using `pack-format` without any arguments or by using flag `--help`/`-h`.
Expand Down
22 changes: 14 additions & 8 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!usr/bin/env node
const VERSION = '1.0.3'
const VERSION = '1.0.4'

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

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

if (arg(1) && !arg(1).includes('-h'))
if (arg(1).includes('-v'))
console.log(`The current version of pack-format is ${VERSION}`)
const arg = n => process.argv[n + 1]

if (arg(1) && !arg(1).includes('-h'))
if (arg(1).includes('-v'))
console.log(`The current version of pack-format is ${VERSION}`)
else
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
else
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
else
console.log('Type `pack-format <version>` to retrieve the pack format of any Minecraft version.')
console.log('Type `pack-format <version>` to retrieve the pack format of any Minecraft version.')

}

module.exports = cli
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const cli = require('./cli.js')

class Snapshot {
constructor(version) { this.version = version }
getYear() { return parseInt(this.version.replace(/^(\d\d).+$/, '$1')) }
Expand Down Expand Up @@ -61,4 +63,8 @@ function getPackFormat(version) {
}
}

if (require.main === module) {
cli()
}

module.exports = getPackFormat
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pack-format",
"version": "1.0.3",
"version": "1.0.4",
"description": "Returns the pack_format of any Minecraft version, including snapshots",
"scripts": {
"test": "node test"
Expand All @@ -13,7 +13,7 @@
],
"main": "index.js",
"bin": {
"pack-format": "cli.js"
"pack-format": "index.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 6e6a6e4

Please sign in to comment.