File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,11 @@ export class YargsParser {
214214 // any unknown option (except for end-of-options, "--")
215215 if ( arg !== '--' && isUnknownOptionAsArg ( arg ) ) {
216216 pushPositional ( arg )
217+ // ---, ---=, ----, etc,
218+ } else if ( arg . match ( / - - - + ( = | $ ) / ) ) {
219+ // options without key name are invalid.
220+ pushPositional ( arg )
221+ continue
217222 // -- separated by =
218223 } else if ( arg . match ( / ^ - - .+ = / ) || (
219224 ! configuration [ 'short-option-groups' ] && arg . match ( / ^ - .+ = / )
Original file line number Diff line number Diff line change @@ -3244,6 +3244,17 @@ describe('yargs-parser', function () {
32443244 k : true
32453245 } )
32463246 } )
3247+ // See: https://github.com/yargs/yargs/issues/1869
3248+ // ----=hello ---=hello ---- hello.
3249+ it ( 'should not populate "--" for key values other than "--"' , ( ) => {
3250+ const argv = parser ( '----=test' , {
3251+ configuration : {
3252+ 'populate--' : true
3253+ }
3254+ } )
3255+ argv . _ . should . eql ( [ '----=test' ] )
3256+ expect ( argv [ '--' ] ) . to . equal ( undefined )
3257+ } )
32473258 // see: https://github.com/yargs/yargs/issues/1489
32483259 it ( 'should identify "hasOwnProperty" as unknown option' , ( ) => {
32493260 const argv = parser ( '--known-arg=1 --hasOwnProperty=33' , {
You can’t perform that action at this time.
0 commit comments