sindresorhus/globby

Prevent search of ignore files in ignored files list

nicolas-goudry opened this issue ยท 1 comments

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch globby@13.2.2 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.

PR welcome, but needs some tests.


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