yargs-parser
Advanced tools
Comparing version 20.0.0 to 20.1.0
@@ -44,2 +44,3 @@ import { tokenizeArgString } from './tokenize-arg-string.js'; | ||
'parse-numbers': true, | ||
'parse-positional-numbers': true, | ||
'populate--': false, | ||
@@ -570,6 +571,9 @@ 'set-placeholder-key': false, | ||
function maybeCoerceNumber(key, value) { | ||
if (!configuration['parse-positional-numbers'] && key === '_') | ||
return value; | ||
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) { | ||
const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(Math.floor(parseFloat(`${value}`)))); | ||
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) | ||
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) { | ||
value = Number(value); | ||
} | ||
} | ||
@@ -968,8 +972,8 @@ return value; | ||
return { | ||
aliases: Object.assign({}, flags.aliases), | ||
argv: Object.assign(argvReturn, argv), | ||
configuration: configuration, | ||
defaulted: Object.assign({}, defaulted), | ||
error: error, | ||
aliases: Object.assign({}, flags.aliases), | ||
newAliases: Object.assign({}, newAliases), | ||
defaulted: Object.assign({}, defaulted), | ||
configuration: configuration | ||
newAliases: Object.assign({}, newAliases) | ||
}; | ||
@@ -976,0 +980,0 @@ } |
@@ -5,2 +5,14 @@ # Changelog | ||
## [20.1.0](https://www.github.com/yargs/yargs-parser/compare/v20.0.0...v20.1.0) (2020-09-20) | ||
### Features | ||
* adds parse-positional-numbers configuration ([#321](https://www.github.com/yargs/yargs-parser/issues/321)) ([9cec00a](https://www.github.com/yargs/yargs-parser/commit/9cec00a622251292ffb7dce6f78f5353afaa0d4c)) | ||
### Bug Fixes | ||
* **build:** update release-please; make labels kick off builds ([#323](https://www.github.com/yargs/yargs-parser/issues/323)) ([09f448b](https://www.github.com/yargs/yargs-parser/commit/09f448b4cd66e25d2872544718df46dab8af062a)) | ||
## [20.0.0](https://www.github.com/yargs/yargs-parser/compare/v19.0.4...v20.0.0) (2020-09-09) | ||
@@ -7,0 +19,0 @@ |
{ | ||
"name": "yargs-parser", | ||
"version": "20.0.0", | ||
"version": "20.1.0", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -5,0 +5,0 @@ "main": "build/index.cjs", |
@@ -246,2 +246,21 @@ # yargs-parser | ||
### parse positional numbers | ||
* default: `true` | ||
* key: `parse-positional-numbers` | ||
Should positional keys that look like numbers be treated as such. | ||
```sh | ||
node example.js 99.3 | ||
{ _: [99] } | ||
``` | ||
_if disabled:_ | ||
```sh | ||
node example.js 99.3 | ||
{ _: ['99.3'] } | ||
``` | ||
### boolean negation | ||
@@ -248,0 +267,0 @@ |
Sorry, the diff of this file is not supported yet
117551
2204
519