-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Using an array as an object key #9
Comments
Is there a test case you can suggest that indicates the problem? |
Actually, the array will be turned into string joined with comma. But regardless, the logic still seems broken to me. |
In which browser is an array used as an object key not toStringed such that it auto-joins? |
My mistake. It something i messed up it seems |
Found the case where it breaks. minimist = require('minimist')
console.log(minimist(["-f123"], {
alias: {
foo: ["f"]
},
string: ["foo"]
}))
/* Outputs:
{ _: [], f: '123', foo: '123' }
Works as intended because flags.strings key will be: {"foo": true, "f": true}
*/
console.log(minimist(["-f123"], {
alias: {
foo: ["f", "g"]
},
string: ["foo"]
}))
/* Outputs:
{ _: [], f: 123, foo: 123, g: 123 }
Broken because flags.strings will be: {"foo": true, "f,g": true}
*/ Its an edge-case, but its still breaks the convention |
The readme indeed says "an object mapping string names to strings or arrays of string argument names to use as aliases", so this seems like a bug. |
Took me a while to make sense of it, but I agree it is a bug. An alias with multiple items does not play well with the (I suspect there are some holes in the combination of aliases with |
Well, aliases cannot be flat without breaking this: Lines 125 to 127 in 62fde7d
|
Consider this block:
minimist/index.js
Lines 52 to 66 in 62fde7d
Here it builds an array of aliased args:
minimist/index.js
Lines 55 to 57 in 62fde7d
And here it uses this array as a key for strings:
minimist/index.js
Line 64 in 62fde7d
Which will just result in:
It should either build flat aliases or iterate over the nested array
The text was updated successfully, but these errors were encountered: