Would be great to support negated patterns in the ignore option.
Use case: respect files like .gitignore (or others like .prettierignore etc) when globbing.
E.g. globby has the gitignore option which does the .gitignore reading, parsing and evaluation.
I wouldn't expect tinyglobby to include this feature (to read and parse such ignore files), but would be great to support negated ignore patterns so tinyglobby could be extended to support the use case.
The same has been requested in both node-glob and fast-glob, but neither of them currently supports it. Refs:
It would make migration more interesting for globby (with gitignore: true) users. Also I understand tinyglobby wants to stay tiny so feel free to reject!
Here's an example simplified use case to clarify things a bit. Let's say we want to glob all **/index.js files in a workspace that has this .gitignore:
.yarn/*
!.yarn/patches
...
And files:
.
├── index.js
└── .yarn
├── patches
│ └── index.js
└── index.js
After reading the .gitignore file(s) and converting the patterns the options look like this:
glob(["**/*.js"], {
dot: true,
ignore: ["**/.yarn/*", "!**/.yarn/patches/**"],
});
Expected result:
["index.js", ".yarn/patches/index.js"]
Just saying, for users to stuff it all into patterns argument directly is likely not a good idea. I think this doesn't and shouldn't work:
glob(["**/*.{js,ts}", "!.yarn", ".yarn/patches/**/*.{js,ts}"], { dot: true })
Would be great to support negated patterns in the
ignoreoption.Use case: respect files like
.gitignore(or others like.prettierignoreetc) when globbing.E.g. globby has the
gitignoreoption which does the.gitignorereading, parsing and evaluation.I wouldn't expect tinyglobby to include this feature (to read and parse such ignore files), but would be great to support negated
ignorepatterns so tinyglobby could be extended to support the use case.The same has been requested in both node-glob and fast-glob, but neither of them currently supports it. Refs:
ignoreoption mrmlnc/fast-glob#86It would make migration more interesting for globby (with
gitignore: true) users. Also I understand tinyglobby wants to stay tiny so feel free to reject!Here's an example simplified use case to clarify things a bit. Let's say we want to glob all
**/index.jsfiles in a workspace that has this.gitignore:And files:
After reading the
.gitignorefile(s) and converting the patterns the options look like this:Expected result:
Just saying, for users to stuff it all into
patternsargument directly is likely not a good idea. I think this doesn't and shouldn't work: