Skip to content

Commit

Permalink
fix: should populate "_" when given config with "short-option-groups"…
Browse files Browse the repository at this point in the history
… false (#179)
  • Loading branch information
MoonBall authored and bcoe committed Jun 7, 2019
1 parent 7f33140 commit 6055974
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function parse (args, opts) {

// -- seperated by space.
} else if (arg.match(/^--.+/) || (
!configuration['short-option-groups'] && arg.match(/^-.+/)
!configuration['short-option-groups'] && arg.match(/^-[^-]+/)
)) {
key = arg.match(/^--?(.+)/)[1]

Expand Down
13 changes: 13 additions & 0 deletions test/yargs-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2442,6 +2442,19 @@ describe('yargs-parser', function () {
result.should.not.have.property('--')
})

it('should populate "_" when given config with "short-option-groups" false', function () {
var result = parser.detailed([
'--', 'foo'
], {
configuration: {
'short-option-groups': false
}
})
result.argv.should.deep.equal({ '_': ['foo'] })
result.argv.should.not.have.property('--')
result.newAliases.should.deep.equal({})
})

it('should populate the "--" if populate-- is "true"', function () {
var result = parser([
'--name=meowmers', 'bare', '-cats', 'woo', 'moxy',
Expand Down

0 comments on commit 6055974

Please sign in to comment.