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

Prevent search of ignore files in ignored files list #258

Closed
nicolas-goudry opened this issue Nov 10, 2023 · 1 comment · Fixed by #259
Closed

Prevent search of ignore files in ignored files list #258

nicolas-goudry opened this issue Nov 10, 2023 · 1 comment · Fixed by #259

Comments

@nicolas-goudry
Copy link
Contributor

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The issue that gave birth to this fix can be found in xo’s repository. You’ll find there all the explanations about why I did need it.

While I believe this is not a great fix (code-wise), it does solve my issue. If you want me to open a PR, I’ll gladly do so! Please let me know 🙂

Here is the diff that solved my problem:

diff --git a/node_modules/globby/ignore.js b/node_modules/globby/ignore.js
index 3d8e1a8..74de387 100644
--- a/node_modules/globby/ignore.js
+++ b/node_modules/globby/ignore.js
@@ -60,12 +60,13 @@ const normalizeOptions = (options = {}) => ({
 	cwd: toPath(options.cwd) || process.cwd(),
 	suppressErrors: Boolean(options.suppressErrors),
 	deep: typeof options.deep === 'number' ? options.deep : Number.POSITIVE_INFINITY,
+  ignore: Array.isArray(options.ignore) ? [...options.ignore, ...ignoreFilesGlobOptions.ignore] : ignoreFilesGlobOptions.ignore
 });
 
 export const isIgnoredByIgnoreFiles = async (patterns, options) => {
-	const {cwd, suppressErrors, deep} = normalizeOptions(options);
+	const {cwd, suppressErrors, deep, ignore} = normalizeOptions(options);
 
-	const paths = await fastGlob(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});
+	const paths = await fastGlob(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions, ignore});
 
 	const files = await Promise.all(
 		paths.map(async filePath => ({
@@ -78,9 +79,9 @@ export const isIgnoredByIgnoreFiles = async (patterns, options) => {
 };
 
 export const isIgnoredByIgnoreFilesSync = (patterns, options) => {
-	const {cwd, suppressErrors, deep} = normalizeOptions(options);
+	const {cwd, suppressErrors, deep, ignore} = normalizeOptions(options);
 
-	const paths = fastGlob.sync(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions});
+	const paths = fastGlob.sync(patterns, {cwd, suppressErrors, deep, ...ignoreFilesGlobOptions, ignore});
 
 	const files = paths.map(filePath => ({
 		filePath,

This issue body was partially generated by patch-package.

@sindresorhus
Copy link
Owner

PR welcome, but needs some tests.


I also think it throwing an error in your case is a bug: #254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants