Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacement for minimatch #52779

Open
sgrishchenko opened this issue May 1, 2024 · 4 comments · May be fixed by #52881
Open

Replacement for minimatch #52779

sgrishchenko opened this issue May 1, 2024 · 4 comments · May be fixed by #52881
Assignees
Labels
feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. path Issues and PRs related to the path subsystem.

Comments

@sgrishchenko
Copy link

What is the problem this feature will solve?

It is great that now in Node 22 there is fs.glob. But it seems that also replacement for minimatch is required. Otherwise, I don't know how to use exclude function from fs.glob options, because it is a frequent scenario when I need to use some glob pattern to exclude files.

What is the feature you are proposing to solve the problem?

I propose to export some helper that matches path string and glob pattern (maybe from path module).

What alternatives have you considered?

The only alternative I see for now is use minimatch package (or package that similar to it).

@sgrishchenko sgrishchenko added the feature request Issues that request new features to be added to Node.js. label May 1, 2024
@RedYetiDev RedYetiDev added the fs Issues and PRs related to the fs subsystem / file system. label May 1, 2024
@MoLow MoLow added the path Issues and PRs related to the path subsystem. label May 2, 2024
@MoLow
Copy link
Member

MoLow commented May 2, 2024

can you give an example of your use case?
do you mean something along the lines of path.matchesPattern(pattern:string, path:string) => boolean?

@sgrishchenko
Copy link
Author

Yes, something like this. E.g. in Vitest docs you can see an example of exclude property in config. If I want to implement a similar approach in my CLI utility that is written in Node, I need to filter out file names that provides fs.glob for me. Unfortunately, I don't see any way how I can do this using current Node API.

Also, I am developing Karakum project. It also CLI util, I use it to convert Typescript definitions to Kotlin/JS definitions. And I also have a similar problem: I need to collect some files using globs, but then I need to ignore some of them (also using glob). Now I use glob and minimatch libraries for it. I considered using native Node API, but I realized that I don't have a replacement for minimatch.

BTW, thanks for asking.

@MoLow
Copy link
Member

MoLow commented May 7, 2024

@RedYetiDev are you interested in picking this up and adding a path.isMatch/path.matchesPattern helper?

@RedYetiDev
Copy link
Member

Sure!

@RedYetiDev RedYetiDev self-assigned this May 7, 2024
@RedYetiDev RedYetiDev linked a pull request May 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. fs Issues and PRs related to the fs subsystem / file system. path Issues and PRs related to the path subsystem.
Projects
Status: Pending Triage
3 participants