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: should populate "_" when "short-option-groups" is false #179

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
2 changes: 1 addition & 1 deletion index.js
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
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