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

Override of array behaviour for boolean option does not work for alias #31

Closed
shadowspawn opened this issue Mar 18, 2023 · 0 comments · Fixed by #34
Closed

Override of array behaviour for boolean option does not work for alias #31

shadowspawn opened this issue Mar 18, 2023 · 0 comments · Fixed by #34

Comments

@shadowspawn
Copy link
Collaborator

There is a test to determine whether an option value should overwrite the previous value, or be added to an array. The test for a boolean option does not take into account the alias. The failure only shows up if the previous value was not a boolean, so not likely to come up in practice.

Found by code inspection, not from usage.

if (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {

const minimist = require('minimist');

const result = minimist(process.argv.slice(2), {
    boolean: ['a', 'bb'],
    alias: { a: 'aa', bb: 'b' }
});

console.log(result);
% node prob2 -a=A -b=B -a -a -b -b
{
  _: [],
  a: true,
  aa: [ 'A', true, true ],
  bb: true,
  b: [ 'B', true, true ]
}
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

Successfully merging a pull request may close this issue.

1 participant