micromatch / micromatch/picomatch
Add `partial` option
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 135
- Avg merge
- 23h 38m
- Merged PRs (30d)
- 7
Description
minimatch has a partial option that seems to do a partial match. This is great for optimizations in path traversal libraries. As per minimatch's docs:
partial
Compare a partial path to a pattern. As long as the parts of the path that
are present are not contradicted by the pattern, it will be treated as a
match. This is useful in applications where you're walking through a
folder structure, and don't yet have the full path, but want to ensure that
you do not walk down paths that can never be a match.For example,
minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
I am building a library that would greatly benefit from this functionality, but I also would rather not switch to minimatch as I greatly value picomatch's advantages in terms of performance. It also seems like I'm not the first one to suggest this, as someone also opened a feature request in micromatch (micromatch/micromatch#276).
Many existing libraries that make use of picomatch (that currently implement this behavior themselves) would also benefit from this, such as fast-glob: https://github.com/mrmlnc/fast-glob/blob/096a5b620f4224eb692bd8ff2c8de0e634e50d8e/src/providers/matchers/partial.ts
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimatch partial option description and the three examples in the issue, then compare the existing behavior with fast-glob's referenced src/providers/matchers/partial.ts. Done means picomatch supports partial paths without contradicting patterns, including the positive and negative cases described, with matching tests added in the repository's existing test structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100