simple-bin-help
Advanced tools
Comparing version 1.6.0 to 1.7.0
40
index.js
@@ -5,2 +5,3 @@ 'use strict' | ||
var wrap = require('word-wrap') | ||
var debug = require('debug')('simple-bin-help') | ||
@@ -15,2 +16,10 @@ function isHelp (arg) { | ||
function isVersion (arg) { | ||
return arg === '-v' || arg === '--version' | ||
} | ||
function hasVersionArgument (args) { | ||
return args.some(isVersion) | ||
} | ||
function noArguments (minLength, args) { | ||
@@ -33,2 +42,3 @@ console.assert(Array.isArray(args), 'missing arguments') | ||
var helpMessage = options.help || options.helpMessage | ||
debug('showHelp options %j', options) | ||
@@ -55,5 +65,6 @@ var pkg = getPackage(options) | ||
if (!pkgInfo && !helpMessage) { | ||
console.log('Incorrect CLI arguments') | ||
console.log('Incorrect CLI arguments (could not find pkg or help)') | ||
if (pkg && pkg.name) { | ||
console.log('Check out instructions for this module using `npm home ' + pkg.name + '`') | ||
console.log('Check out instructions for this module using `npm home ' + | ||
pkg.name + '`') | ||
} | ||
@@ -70,2 +81,6 @@ } | ||
function showVersion (pkg) { | ||
console.log(pkg.name, pkg.version) | ||
} | ||
function simpleBinHelp (options, cliArguments) { | ||
@@ -77,4 +92,6 @@ console.assert(options, 'missing options') | ||
} | ||
debug('options %j cli arguments %j', options, cliArguments) | ||
if (hasHelpArgument(cliArguments)) { | ||
debug('has CLI help argument') | ||
showHelp(options) | ||
@@ -86,2 +103,14 @@ finish(options) | ||
var pkg = getPackage(options) | ||
if (pkg) { | ||
debug('found package %s %s', pkg.name, pkg.version) | ||
} else { | ||
debug('could not get package from options %j', options) | ||
} | ||
if (pkg && hasVersionArgument(cliArguments)) { | ||
showVersion(pkg) | ||
finish(options) | ||
return true | ||
} | ||
if (pkg && pkg.name && pkg.version) { | ||
@@ -109,1 +138,8 @@ updateNotifier({ pkg: pkg }).notify() | ||
module.exports = simpleBinHelp | ||
if (!module.parent) { | ||
simpleBinHelp({ | ||
packagePath: './package.json', | ||
help: 'test help message' | ||
}) | ||
} |
@@ -5,3 +5,3 @@ { | ||
"main": "index.js", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"scripts": { | ||
@@ -13,4 +13,4 @@ "test": "mocha --harmony spec", | ||
"size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";", | ||
"lint": "standard *.js spec/*.js examples/*.js", | ||
"basic": "node --harmony examples/basic.js" | ||
"lint": "standard --fix *.js spec/*.js examples/*.js", | ||
"basic": "NODE_PATH=.. node --harmony examples/basic.js" | ||
}, | ||
@@ -41,13 +41,13 @@ "files": [ | ||
"devDependencies": { | ||
"check-more-types": "2.2.0", | ||
"git-issues": "1.2.0", | ||
"lazy-ass": "1.1.0", | ||
"mocha": "2.3.4", | ||
"pre-git": "2.0.2", | ||
"semantic-release": "4.3.5", | ||
"standard": "5.4.1" | ||
"check-more-types": "2.24.0", | ||
"git-issues": "1.3.1", | ||
"lazy-ass": "1.6.0", | ||
"mocha": "3.4.2", | ||
"pre-git": "3.15.0", | ||
"semantic-release": "^6.3.6", | ||
"standard": "10.0.2" | ||
}, | ||
"config": { | ||
"pre-git": { | ||
"commit-msg": "validate-commit-msg", | ||
"commit-msg": "simple", | ||
"pre-commit": [ | ||
@@ -66,5 +66,6 @@ "npm run lint", | ||
"dependencies": { | ||
"update-notifier": "0.5.0", | ||
"word-wrap": "1.1.0" | ||
"debug": "2.6.8", | ||
"update-notifier": "2.1.0", | ||
"word-wrap": "1.2.3" | ||
} | ||
} |
@@ -8,4 +8,2 @@ # simple-bin-help | ||
[![Build status][simple-bin-help-ci-image] ][simple-bin-help-ci-url] | ||
[![dependencies][simple-bin-help-dependencies-image] ][simple-bin-help-dependencies-url] | ||
[![devdependencies][simple-bin-help-devdependencies-image] ][simple-bin-help-devdependencies-url] | ||
[![semantic-release][semantic-image] ][semantic-url] | ||
@@ -67,5 +65,12 @@ [![standard](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) | ||
* Includes and calls the [update-notifier]() module by default. | ||
* Includes and calls the [update-notifier][update-notifier] module by default. | ||
* If passed `-h` or `--help` option, shows the help message. | ||
* If passed `-v` or `--version` option, shows the package version. | ||
[update-notifier]: https://github.com/yeoman/update-notifier#readme | ||
## Debug | ||
Run code with `DEBUG=simple-bin-help ...` environment variable | ||
### Small print | ||
@@ -76,4 +81,4 @@ | ||
* [@bahmutov](https://twitter.com/bahmutov) | ||
* [glebbahmutov.com](http://glebbahmutov.com) | ||
* [blog](http://glebbahmutov.com/blog/) | ||
* [glebbahmutov.com](https://glebbahmutov.com) | ||
* [blog](https://glebbahmutov.com/blog/) | ||
@@ -112,11 +117,7 @@ License: MIT - do anything with the code, but don't blame me if it does not work. | ||
[simple-bin-help-icon]: https://nodei.co/npm/simple-bin-help.png?downloads=true | ||
[simple-bin-help-icon]: https://nodei.co/npm/simple-bin-help.svg?downloads=true | ||
[simple-bin-help-url]: https://npmjs.org/package/simple-bin-help | ||
[simple-bin-help-ci-image]: https://travis-ci.org/bahmutov/simple-bin-help.png?branch=master | ||
[simple-bin-help-ci-image]: https://travis-ci.org/bahmutov/simple-bin-help.svg?branch=master | ||
[simple-bin-help-ci-url]: https://travis-ci.org/bahmutov/simple-bin-help | ||
[simple-bin-help-dependencies-image]: https://david-dm.org/bahmutov/simple-bin-help.png | ||
[simple-bin-help-dependencies-url]: https://david-dm.org/bahmutov/simple-bin-help | ||
[simple-bin-help-devdependencies-image]: https://david-dm.org/bahmutov/simple-bin-help/dev-status.png | ||
[simple-bin-help-devdependencies-url]: https://david-dm.org/bahmutov/simple-bin-help#info=devDependencies | ||
[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg | ||
[semantic-url]: https://github.com/semantic-release/semantic-release |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8601
109
120
3
+ Addeddebug@2.6.8
+ Addedansi-align@2.0.0(transitive)
+ Addedansi-regex@3.0.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedboxen@1.3.0(transitive)
+ Addedcamelcase@4.1.0(transitive)
+ Addedcapture-stack-trace@1.0.2(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcli-boxes@1.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedconfigstore@3.1.5(transitive)
+ Addedcreate-error-class@3.0.2(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addedcrypto-random-string@1.0.0(transitive)
+ Addeddebug@2.6.8(transitive)
+ Addeddot-prop@4.2.1(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedexeca@0.7.0(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedgot@6.7.1(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedis-obj@1.0.1(transitive)
+ Addedis-retry-allowed@1.2.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlatest-version@3.1.0(transitive)
+ Addedlazy-req@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedpackage-json@4.0.1(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedregistry-auth-token@3.4.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedterm-size@1.2.0(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedunique-string@1.0.0(transitive)
+ Addedunzip-response@2.0.1(transitive)
+ Addedupdate-notifier@2.1.0(transitive)
+ Addedurl-parse-lax@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwidest-line@2.0.1(transitive)
+ Addedword-wrap@1.2.3(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedxdg-basedir@3.0.0(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedconfigstore@1.4.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedduplexify@3.7.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedgot@3.3.1(transitive)
- Removedinfinity-agent@2.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-finite@1.1.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlatest-version@1.0.1(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednested-error-stacks@1.0.2(transitive)
- Removedobject-assign@3.0.04.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedos-tmpdir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedpackage-json@1.2.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedrepeating@1.1.3(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedslide@1.1.6(transitive)
- Removedstream-shift@1.0.3(transitive)
- Removedstring-length@1.0.1(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtimed-out@2.0.0(transitive)
- Removedupdate-notifier@0.5.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@2.0.3(transitive)
- Removedword-wrap@1.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)
- Removedxdg-basedir@2.0.0(transitive)
Updatedupdate-notifier@2.1.0
Updatedword-wrap@1.2.3