Skip to content

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
- if the version is set, don't try to print the version in the parent directory
  • Loading branch information
gabrielcsapo committed Jan 10, 2018
1 parent e637d73 commit 170afa5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 0.2.0 (01/04/2017)
# 0.2.1 (01/09/2018)

- if the version is set, don't try to print the version in the parent directory

# 0.2.0 (01/04/2018)

- augments command and flag objects into hashmaps for faster lookup than array traversal
- condenses help and version logic by also making lookup via hashmap
Expand Down
15 changes: 9 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ module.exports = function Woof(helpMessage, options={}) {
program['version'] = true;

// If the version is provided, just use that
if(version) process.stdout.write(`v${version}\n`);
// try to get the version from the current applications package.json
try {
process.stdout.write(`v${require(`${parentDir}/package.json`).version}\n`);
} catch(ex) {
process.stdout.write('v?\n');
if(version) {
process.stdout.write(`v${version}\n`);
} else {
// try to get the version from the current applications package.json
try {
process.stdout.write(`v${require(`${parentDir}/package.json`).version}\n`);
} catch(ex) {
process.stdout.write('v?\n');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woof",
"version": "0.2.0",
"version": "0.2.1",
"description": "🐶 command line applications made as easy as fetch",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 170afa5

Please sign in to comment.