bmatcuk / doublestar

Implements support for double star (**) matches in golang's path.Match and filepath.Glob.
MIT License
504 stars 54 forks source link

Support for extglob? #87

Open rishabh-arya95 opened 1 year ago

rishabh-arya95 commented 1 year ago

I was writing a utility to detect test files for various javascript test frameworks. Was trying to use the glob pattern mentioned here https://playwright.dev/docs/api/class-testconfig#test-config-test-match, but it seems the pattern **/*.@(spec|test).?(c|m)[jt]s?(x) is not matching the file paths like login-screen.wrong-credentials.spec.ts

doublestar.Match(`**/*.@(spec|test).?(c|m)[jt]s?(x)`,  "test/login-screen.wrong-credentials.test.ts") // returns false

I have also tried testing in this online tool, here the result passes

bmatcuk commented 1 year ago

doublestar does not support this syntax... but this might work: **/*.{spec,test}.{c,m,}[jt]s{x,}

rishabh-arya95 commented 1 year ago

Yes, this does certainly work, I see you have marked it as an enhancement. It will be great if extended globbing support is also added, sharing this popular library https://github.com/micromatch/extglob which has implemented this for js

bmatcuk commented 1 year ago

It's not likely something I'd get in to doublestar any time soon, unfortunately... and it's a bit out-of-scope for what the library is trying to accomplish (which is just to implement **). But I keep a list of feature requests and if I ever find the time, I'll see what I can do.