Skip to content

Commit 57b7883

Browse files
juergbaBenjamin E. Coe
authored andcommitted
fix: convert values to strings when tokenizing (#167)
1 parent 6055974 commit 57b7883

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎lib/tokenize-arg-string.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// take an un-split argv string and tokenize it.
22
module.exports = function (argString) {
3-
if (Array.isArray(argString)) return argString
3+
if (Array.isArray(argString)) {
4+
return argString.map(e => typeof e !== 'string' ? e + '' : e)
5+
}
46

57
argString = argString.trim()
68

‎test/tokenize-arg-string.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ describe('TokenizeArgString', function () {
1212
args[1].should.equal('99')
1313
})
1414

15+
it('handles unquoted numbers', function () {
16+
var args = tokenizeArgString(['--foo', 9])
17+
args[0].should.equal('--foo')
18+
args[1].should.equal('9')
19+
})
20+
1521
it('handles quoted string with no spaces', function () {
1622
var args = tokenizeArgString("--foo 'hello'")
1723
args[0].should.equal('--foo')

0 commit comments

Comments
 (0)