fix(defaults): Process help and version defaults better#116
fix(defaults): Process help and version defaults better#116ntwcklng merged 7 commits intoleo:masterfrom markhalliwell:version-help-fix
Conversation
Also removes unnecessary "pkginfo" dependency
|
Awesome PR! Would you mind and add tests for both cases like |
feat(config): Add "exit" booleans for help and version fix(help): Clone objects in array so original data is not altered Fixes #95
|
Ok, I've gone ahead and added separate tests (which really need some love and to be separated even more BTW). I ended up having to implement an Found a nifty little bug in Removed the Updated the docs as well. |
|
Seems Travis is having some network issues. Any chance the last commit test can be restarted? |
|
Cleaned up the version code a bit so it uses I also went ahead and provided a summary of changes for the PR. I think I'm done tinkering with this, for now, don't want to scope creep too much. |
* More compact layout (leo/args#124) * Fix options parsing (leo/args#116) * Updates dependencies * https://github.com/leo/args/releases/tag/5.0.0 * https://github.com/leo/args/releases/tag/4.0.0
* More compact layout (leo/args#124) * Fix options parsing (leo/args#116) * Updates dependencies * https://github.com/leo/args/releases/tag/5.0.0 * https://github.com/leo/args/releases/tag/4.0.0
* fix(defaults): Process help and version defaults better Also removes unnecessary "pkginfo" dependency * fix(command): Pass any options that appear before a command * task(version): Remove unnecessary parent parameter introduced in #96 feat(config): Add "exit" booleans for help and version fix(help): Clone objects in array so original data is not altered Fixes #95 * test(options): Add assertions to ensure "help" and "version" options work properly * docs(options): Add ".showVersion()" method and "exit" configuration * fix(generateDetails): Use Object.assign instead of spread for older node versions * fix(version): Use process.mainModule instead of module.parent
The predefined
helpandversionoptions are hardcoded to the lowercase characters when checking if they were provided.This causes issues if other options like
hostorverboseare provided first, which actually does cause thehelpandversionshort options to be uppercased, but are ultimately ignored.Summary of changes:
Fixes
help/versionshort options. If someone provides-vforverbose, they actually get the version printed out and the process exits (this may also possibly help with subcommands can't have a --version option #103 somewhat):Before:
foo bar -v->1.0.0After:
foo bar -v->Verbose output from barBefore:
foo -dv bar -f file.txt->foo-bar -f file.txtAfter:
foo -dv bar -f file.txt->foo-bar -dv -f file.txtgenerateDetailswhere it was overriding theusageproperty on the items it was generating, which in turn was also altering the original object and causing the tests to bork.Added
exitconfig option like was described in Support for evaluating without exiting #95 (needed for tests)Removed
parentparameter that was added tocheckVersionin pass in parent module fromindex.js#96. Since this was only introduced in 3.0.2 and has remained an internal method (not exposed until now), there's no real risk of breaking BC.pkginfodependency - This module is unnecessary and, quite frankly, a little too presumptuous in populating metadata onto the module object. While, perhaps useful for other projects, it is overkill for simply attempting to retrieve the main module's version.