tinyglobby icon indicating copy to clipboard operation
tinyglobby copied to clipboard

Export a function to check if a path matches a pattern

Open sdorra opened this issue 5 months ago • 2 comments

First of all, thank you for the great library. I'm using tinyglobby in one of my projects to collect files from a directory. After I collect them, I start watching that directory for changes. Whenever a change occurs, I need to check if the modified path matches the same pattern used to collect the files with tinyglobby. I have used picomatch to verify the path against the pattern since it is the same library used by tinyglobby. However, it seems that tinyglobby does more than just checking the raw path with picomatch. There are cases where tinyglobby matches a file, but the check with picomatch fails (e.g., sdorra/content-collections#602). It would be helpful if tinyglobby could export a function that allows checking if a path matches a pattern, using the same logic as the main function to match the path.

sdorra avatar Jul 09 '25 07:07 sdorra

is there any specific functionality you want that picomatch doesn't have? the vitest folks asked for the same in #64 but ended up fine with just picomatch

SuperchupuDev avatar Jul 09 '25 09:07 SuperchupuDev

is there any specific functionality you want that picomatch doesn't have?

I'm not sure. I need a function that matches exactly like tinyglobby does.

When I use plain picomatch, I find that tinyglobby matches a file while picomatch does not. For example, in sdorra/content-collections#602, tinyglobby matches the path with Windows separators, but picomatch does not.

sdorra avatar Jul 10 '25 07:07 sdorra