yargs-parser
Advanced tools
Comparing version 17.1.0 to 18.0.0
@@ -5,2 +5,13 @@ # Changelog | ||
## [18.0.0](https://www.github.com/yargs/yargs-parser/compare/v17.1.0...v18.0.0) (2020-03-02) | ||
### ⚠ BREAKING CHANGES | ||
* the narg count is now enforced when parsing arrays. | ||
### Features | ||
* NaN can now be provided as a value for nargs, indicating "at least" one value is expected for array ([#251](https://www.github.com/yargs/yargs-parser/issues/251)) ([9db4be8](https://www.github.com/yargs/yargs-parser/commit/9db4be81417a2c7097128db34d86fe70ef4af70c)) | ||
## [17.1.0](https://www.github.com/yargs/yargs-parser/compare/v17.0.1...v17.1.0) (2020-03-01) | ||
@@ -7,0 +18,0 @@ |
17
index.js
@@ -364,3 +364,6 @@ const camelCase = require('camelcase') | ||
let ii | ||
const toEat = checkAllAliases(key, flags.nargs) | ||
let toEat = checkAllAliases(key, flags.nargs) | ||
// NaN has a special meaning for the array type, indicating that one or | ||
// more values are expected. | ||
toEat = isNaN(toEat) ? 1 : toEat | ||
@@ -401,2 +404,4 @@ if (toEat === 0) { | ||
let next = args[i + 1] | ||
// If both array and nargs are configured, enforce the nargs count: | ||
const nargsCount = checkAllAliases(key, flags.nargs) | ||
@@ -418,3 +423,4 @@ if (checkAllAliases(key, flags.bools) && !(/^(true|false)$/.test(next))) { | ||
argsToSet.push(processValue(key, next)) | ||
if (!configuration['greedy-arrays']) break | ||
if (!configuration['greedy-arrays'] || | ||
(nargsCount && argsToSet.length >= nargsCount)) break | ||
} | ||
@@ -424,5 +430,6 @@ } | ||
// If both array and nargs are configured, create an error if less than | ||
// nargs positionals were found: | ||
const toEat = checkAllAliases(key, flags.nargs) | ||
if (toEat && argsToSet.length < toEat) { | ||
// nargs positionals were found. NaN has special meaning, indicating | ||
// that at least one value is required (more are okay). | ||
if ((nargsCount && argsToSet.length < nargsCount) || | ||
(isNaN(nargsCount) && argsToSet.length === 0)) { | ||
error = Error(__('Not enough arguments following: %s', key)) | ||
@@ -429,0 +436,0 @@ } |
{ | ||
"name": "yargs-parser", | ||
"version": "17.1.0", | ||
"version": "18.0.0", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
68857
909
0