Skip to content

boolean-negation + unknown-options-as-args strange behaviour #376

@ArthurKa

Description

@ArthurKa

Node.js: v14.15.2
yargs-parser: v20.2.7

const yargsParser = require('yargs-parser');

const opts = {
  string: ['asd'],
  configuration: {
    'boolean-negation': false,
    'camel-case-expansion': false,
    'unknown-options-as-args': true,
  },
};

console.log(yargsParser('--no-asd2 123', opts));  // { _: [ '--no-asd2', 123 ] }
console.log(yargsParser('--no-asd 123', opts));  // { _: [], 'no-asd': 123 }

Is it correct behaviour? Because of 'boolean-negation': false I was expecting similar output { _: [ '--no-asd', 123 ] }.


Fixed that by adding 'negation-prefix': Math.random().toString(36).slice(2) to configuration. But that would be better to fix it under the hood :) Thanks!


UPD: even 'negation-prefix': '' works fine.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions