Skip to content

Commit

Permalink
Ignore multiple spaces between arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike111177 committed Aug 29, 2017
1 parent 18eae4c commit f0d2276
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/tokenize-arg-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module.exports = function (argString) {

// split on spaces unless we're in quotes.
if (c === ' ' && !opening) {
i++
if (!(prevC===' ')) {
i++
}
continue
}

Expand Down
8 changes: 8 additions & 0 deletions test/tokenize-arg-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var tokenizeArgString = require('../lib/tokenize-arg-string')

require('chai').should()
var expect = require('chai').expect

describe('TokenizeArgString', function () {
it('handles unquoted string', function () {
Expand Down Expand Up @@ -44,4 +45,11 @@ describe('TokenizeArgString', function () {
args[0].should.equal('-q')
args[1].should.equal('sku="invalid"')
})

it('multiple spaces only counted in quotes', function () {
var args = tokenizeArgString('foo bar "foo bar"')
args[0].should.equal('foo')
expect(args[1]).equal('bar')
expect(args[2]).equal('foo bar')
})
})

0 comments on commit f0d2276

Please sign in to comment.