Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: "TypeError: next.match is not a function" with "number" values #167

Merged
merged 1 commit into from Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/tokenize-arg-string.js
@@ -1,6 +1,8 @@
// take an un-split argv string and tokenize it.
module.exports = function (argString) {
if (Array.isArray(argString)) return argString
if (Array.isArray(argString)) {
return argString.map(e => typeof e !== 'string' ? e + '' : e)
}

argString = argString.trim()

Expand Down
6 changes: 6 additions & 0 deletions test/tokenize-arg-string.js
Expand Up @@ -12,6 +12,12 @@ describe('TokenizeArgString', function () {
args[1].should.equal('99')
})

it('handles unquoted numbers', function () {
var args = tokenizeArgString(['--foo', 9])
args[0].should.equal('--foo')
args[1].should.equal('9')
})

it('handles quoted string with no spaces', function () {
var args = tokenizeArgString("--foo 'hello'")
args[0].should.equal('--foo')
Expand Down