Skip to content

Commit 52b0e87

Browse files
committed
process values of number[]
1 parent 17ca3bd commit 52b0e87

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ function parse (args, opts) {
470470
if (typeof val === 'string') val = val === 'true'
471471
}
472472

473-
var value = maybeCoerceNumber(key, val)
473+
var value = Array.isArray(val)
474+
? val.map(function (v) { return maybeCoerceNumber(key, v) })
475+
: maybeCoerceNumber(key, val)
474476

475477
// increment a count given as arg (either no value or value parsed as boolean)
476478
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
@@ -486,7 +488,7 @@ function parse (args, opts) {
486488
}
487489

488490
function maybeCoerceNumber (key, value) {
489-
if (!checkAllAliases(key, flags.strings)) {
491+
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
490492
const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (
491493
Number.isSafeInteger(Math.floor(value))
492494
)

0 commit comments

Comments
 (0)