yargs-parser
Advanced tools
Comparing version 16.0.0 to 16.1.0
@@ -5,3 +5,3 @@ # Changelog | ||
## [16.0.0](https://www.github.com/yargs/yargs-parser/compare/v15.0.0...v16.0.0) (2019-10-26) | ||
## [16.1.0](https://www.github.com/yargs/yargs-parser/compare/v16.0.0...v16.1.0) (2019-11-01) | ||
@@ -11,14 +11,13 @@ | ||
* moving to c8 for coverage and dropping Node 6 from build matrix (#209) | ||
* populate error if incompatible narg/count or array/count options are used (#191) | ||
### Bug Fixes | ||
### Features | ||
* **unknown-options-as-args:** '--' is not an unknown option ([#207](https://www.github.com/yargs/yargs-parser/issues/207)) ([3fee2d8](https://www.github.com/yargs/yargs-parser/commit/3fee2d895e9da14af978bbd1c7c9c20170c3aa59)) | ||
* address issue with array options with array default values ([#206](https://www.github.com/yargs/yargs-parser/issues/206)) ([f5f9e5a](https://www.github.com/yargs/yargs-parser/commit/f5f9e5a7ea91821f7c95e8eb4c71dc74de1bc907)) | ||
* support negative numbers with decimal places ([#208](https://www.github.com/yargs/yargs-parser/issues/208)) ([850bbda](https://www.github.com/yargs/yargs-parser/commit/850bbdafcf8a4998f374dfce993422855d10716d)) | ||
* options that have had their default value used are now tracked ([#211](https://www.github.com/yargs/yargs-parser/issues/211)) ([a525234](https://www.github.com/yargs/yargs-parser/commit/a525234558c847deedd73f8792e0a3b77b26e2c0)) | ||
* populate error if incompatible narg/count or array/count options are used ([#191](https://www.github.com/yargs/yargs-parser/issues/191)) ([84a401f](https://www.github.com/yargs/yargs-parser/commit/84a401f0fa3095e0a19661670d1570d0c3b9d3c9)) | ||
### Build System | ||
### Reverts | ||
* moving to c8 for coverage and dropping Node 6 from build matrix ([#209](https://www.github.com/yargs/yargs-parser/issues/209)) ([f3a9316](https://www.github.com/yargs/yargs-parser/commit/f3a9316e470b0cc5c01981c9614ee935835d719b)) | ||
* revert 16.0.0 CHANGELOG entry ([920320a](https://www.github.com/yargs/yargs-parser/commit/920320ad9861bbfd58eda39221ae211540fc1daf)) | ||
@@ -25,0 +24,0 @@ ## [15.0.0](https://github.com/yargs/yargs-parser/compare/v14.0.0...v15.0.0) (2019-10-07) |
23
index.js
@@ -38,2 +38,3 @@ var camelCase = require('camelcase') | ||
var newAliases = {} | ||
var defaulted = {} | ||
// allow a i18n handler to be passed in, default to a fake one (util.format). | ||
@@ -135,2 +136,4 @@ var __ = opts.__ || util.format | ||
checkConfiguration() | ||
var argv = { _: [] } | ||
@@ -320,3 +323,3 @@ var notFlags = [] | ||
setConfigObjects() | ||
applyDefaultsAndAliases(argv, flags.aliases, defaults) | ||
applyDefaultsAndAliases(argv, flags.aliases, defaults, true) | ||
applyCoercions(argv) | ||
@@ -631,6 +634,7 @@ if (configuration['set-placeholder-key']) setPlaceholderKeys(argv) | ||
function applyDefaultsAndAliases (obj, aliases, defaults) { | ||
function applyDefaultsAndAliases (obj, aliases, defaults, canLog = false) { | ||
Object.keys(defaults).forEach(function (key) { | ||
if (!hasKey(obj, key.split('.'))) { | ||
setKey(obj, key.split('.'), defaults[key]) | ||
if (canLog) defaulted[key] = true | ||
@@ -881,2 +885,16 @@ ;(aliases[key] || []).forEach(function (x) { | ||
// check user configuration settings for inconsistencies | ||
function checkConfiguration () { | ||
// count keys should not be set as array/narg | ||
Object.keys(flags.counts).find(key => { | ||
if (checkAllAliases(key, flags.arrays)) { | ||
error = Error(__('Invalid configuration: %s, opts.count excludes opts.array.', key)) | ||
return true | ||
} else if (checkAllAliases(key, flags.nargs)) { | ||
error = Error(__('Invalid configuration: %s, opts.count excludes opts.narg.', key)) | ||
return true | ||
} | ||
}) | ||
} | ||
return { | ||
@@ -887,2 +905,3 @@ argv: argv, | ||
newAliases: newAliases, | ||
defaulted: defaulted, | ||
configuration: configuration | ||
@@ -889,0 +908,0 @@ } |
{ | ||
"name": "yargs-parser", | ||
"version": "16.0.0", | ||
"version": "16.1.0", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -102,6 +102,10 @@ # yargs-parser | ||
* `_`: an array representing the positional arguments. | ||
* [optional] `--`: an array with arguments after the end-of-options flag `--`. | ||
* `error`: populated with an error object if an exception occurred during parsing. | ||
* `aliases`: the inferred list of aliases built by combining lists in `opts.alias`. | ||
* `newAliases`: any new aliases added via camel-case expansion. | ||
* `configuration`: the configuration loaded from the `yargs` stanza in package.json. | ||
* `newAliases`: any new aliases added via camel-case expansion: | ||
* `boolean`: `{ fooBar: true }` | ||
* `defaulted`: any new argument created by `opts.default`, no aliases included. | ||
* `boolean`: `{ foo: true }` | ||
* `configuration`: given by default settings and `opts.configuration`. | ||
@@ -108,0 +112,0 @@ <a name="configuration"></a> |
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
63609
875
423