Skip to content

Commit 26643e0

Browse files
committed
merge PR187
1 parent 17ca3bd commit 26643e0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
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
)

test/yargs-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ describe('yargs-parser', function () {
24532453
'flatten-duplicate-arrays': false
24542454
}
24552455
})
2456-
parsed['x'].should.deep.equal([1, 2, 3])
2456+
parsed['x'].should.deep.equal([[1], [2], [3]])
24572457
})
24582458
it('[-x 1 2 3 -x 2 3 4] => [[1, 2, 3], [ 2, 3, 4]]', function () {
24592459
var parsed = parser('-x 1 2 3 -x 2 3 4', {

0 commit comments

Comments
 (0)