`@action/glob`: expose a public method to test patterns on given paths
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the enhancement
The globber instance returned by glob.create should have a method test(path: string): boolean returning whether the given path matches the patterns provided on creation.
Additional information
Currently @actions/glob only allows to use a pattern to iterate through actual files existing on the runner at the time of execution. There are however use cases where we want to know which files from a given list match against a list of patterns.
We have such a use case where we first fetch the list of files changed by a PR (via a paginated oktokit's rest.pulls.listFiles request), and we want to filter them with a list of patterns, in a way consistent with how glob patterns work across github actions.
@actions/glob would seem like the library of choice for this, but because it insists on providing existing files it's not of immediate use. I ended up recreating a tree structure of empty files from the list of modified files to appease @actions/glob, but a test method would be much more natural to use. As far as I can tell this would just require exporting functionality that is already present in the library implementation.
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 at the @actions/glob implementation behind glob.create and trace the existing pattern-matching functionality that currently operates on files found on the runner. Expose a test(path: string): boolean method that evaluates the supplied path against the creation patterns, and verify it with paths that do and do not match.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100