Skip to content

Commit 57b7883

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

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: lib/tokenize-arg-string.js

+3-1
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

Diff for: test/tokenize-arg-string.js

+6
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)