Skip to content

Commit f34ead9

Browse files
Mike111177bcoe
authored andcommitted
fix: tokenizer should ignore spaces at the beginning of the argString (#106)
1 parent ce45bcd commit f34ead9

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

lib/tokenize-arg-string.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
module.exports = function (argString) {
33
if (Array.isArray(argString)) return argString
44

5+
argString = argString.trim()
6+
57
var i = 0
68
var prevC = null
79
var c = null

test/tokenize-arg-string.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ describe('TokenizeArgString', function () {
3939
args[2].should.equal('--bar=foo "bar"')
4040
})
4141

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

0 commit comments

Comments
 (0)