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

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

Open
ArthurKa opened this issue Apr 21, 2021 · 0 comments
Open

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

ArthurKa opened this issue Apr 21, 2021 · 0 comments

Comments

@ArthurKa
Copy link
Contributor

ArthurKa commented Apr 21, 2021

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.

@ArthurKa ArthurKa changed the title unknown-options-as-args strange behaviour boolean-negation strange behaviour Apr 21, 2021
@ArthurKa ArthurKa changed the title boolean-negation strange behaviour boolean-negation + unknown-options-as-args strange behaviour Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant