Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/yargs-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ export class YargsParser {
// any unknown option (except for end-of-options, "--")
if (arg !== '--' && isUnknownOptionAsArg(arg)) {
pushPositional(arg)
// ---, ---=, ----, etc,
} else if (arg.match(/---+(=|$)/)) {
// options without key name are invalid.
pushPositional(arg)
continue
// -- separated by =
} else if (arg.match(/^--.+=/) || (
!configuration['short-option-groups'] && arg.match(/^-.+=/)
Expand Down
11 changes: 11 additions & 0 deletions test/yargs-parser.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3244,6 +3244,17 @@ describe('yargs-parser', function () {
k: true
})
})
// See: https://github.com/yargs/yargs/issues/1869
// ----=hello ---=hello ---- hello.
it('should not populate "--" for key values other than "--"', () => {
const argv = parser('----=test', {
configuration: {
'populate--': true
}
})
argv._.should.eql(['----=test'])
expect(argv['--']).to.equal(undefined)
})
// see: https://github.com/yargs/yargs/issues/1489
it('should identify "hasOwnProperty" as unknown option', () => {
const argv = parser('--known-arg=1 --hasOwnProperty=33', {
Expand Down