diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 764ca64e..3ca66151 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -395,7 +395,7 @@ export class YargsParser { notFlags = args.slice(i + 1) break } else if (configuration['halt-at-non-option']) { - notFlags = args.slice(i) + args.slice(i).forEach(pushPositional) break } else { pushPositional(arg) diff --git a/test/yargs-parser.cjs b/test/yargs-parser.cjs index 492e3b90..1608fec6 100644 --- a/test/yargs-parser.cjs +++ b/test/yargs-parser.cjs @@ -2997,6 +2997,17 @@ describe('yargs-parser', function () { }) }) + it('should push to _ when populate-- is true', function () { + const parse = parser( + ['--foo', './file.js', '--foo', '--', 'barbar', '--bar'], + { configuration: { 'halt-at-non-option': true, 'populate--': true }, boolean: ['foo', 'bar'] } + ) + parse.should.deep.equal({ + foo: true, + _: ['./file.js', '--foo', '--', 'barbar', '--bar'] + }) + }) + it('is not influenced by unknown options', function () { const parse = parser( ['-v', '--long', 'arg', './file.js', '--foo', '--', 'barbar'],