Prevent search of ignore files in ignored files list
nicolas-goudry opened this issue ยท 1 comments
nicolas-goudry commented
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.
sindresorhus commented