Skip to content

Commit

Permalink
fix: tokenizer should ignore spaces at the beginning of the argString (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike111177 authored and bcoe committed Dec 1, 2017
1 parent ce45bcd commit f34ead9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/tokenize-arg-string.js
Expand Up @@ -2,6 +2,8 @@
module.exports = function (argString) {
if (Array.isArray(argString)) return argString

argString = argString.trim()

var i = 0
var prevC = null
var c = null
Expand Down
6 changes: 4 additions & 2 deletions test/tokenize-arg-string.js
Expand Up @@ -39,8 +39,10 @@ describe('TokenizeArgString', function () {
args[2].should.equal('--bar=foo "bar"')
})

it('multiple spaces only counted in quotes', function () {
var args = tokenizeArgString('foo bar "foo bar"')
// https://github.com/yargs/yargs-parser/pull/100
// https://github.com/yargs/yargs-parser/pull/106
it('ignores unneeded spaces', function () {
var args = tokenizeArgString(' foo bar "foo bar" ')
args[0].should.equal('foo')
expect(args[1]).equal('bar')
expect(args[2]).equal('foo bar')
Expand Down

0 comments on commit f34ead9

Please sign in to comment.