micromatch / braces

Faster brace expansion for node.js. Besides being faster, braces is not subject to DoS attacks like minimatch, is more accurate, and has more complete support for Bash 4.3.
https://github.com/jonschlinkert
MIT License
207 stars 47 forks source link

Braces with a single value are not expanded #32

Closed iiroj closed 3 years ago

iiroj commented 3 years ago

Hello,

I'm not sure if this is a feature or not, but braces containing only a single value do not get expanded properly.

Two values work fine:

❯ node -e "console.log(require('braces')('{x,y}', { expand:true }))"
[ 'x', 'y' ]

However, only a single value doesn't:

❯ node -e "console.log(require('braces')('{x}', { expand:true }))" 
[ '{x}' ]

I would expect it to instead return:

❯ node -e "console.log(require('braces')('{x}', { expand:true }))" 
[ 'x' ]
jonschlinkert commented 3 years ago

This is correct behavior, per bash. This is documented on the readme: https://github.com/micromatch/braces/blob/98414f9f1fabe021736e26836d8306d5de747e0d/README.md#escaping

Do:

$ echo a{a,b}
$ echo a{b}
jonschlinkert commented 3 years ago

Closing since I think this is resolved. Please feel free to reopen if you think this needs to be discussed further.

iiroj commented 3 years ago

Thanks! It makes sense. It's just a common misconfiguration issue with lint-staged, where users write globs like *.{jsx,tsx} and then also *.{json}. I think we just need to add something about it to the README. These are used for micromatch.

jonschlinkert commented 3 years ago

Totally understand! I’ve done it as well!

Sent from my iPhone

On Apr 15, 2021, at 11:36 PM, Iiro Jäppinen @.***> wrote:

 Thanks! It makes sense. It's just a common misconfiguration issue with lint-staged, where users write globs like .{jsx,tsx} and then also .{json}. I think we just need to add something about it to the README. These are used for micromatch.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.