feat(#1496): handling edge cases for ignore config

This commit is contained in:
Anoop M D 2024-02-05 03:27:20 +05:30
parent cb95b5f36a
commit 123bf198a3
2 changed files with 13 additions and 2 deletions

View File

@ -63,7 +63,10 @@ const openCollection = async (win, watcher, collectionPath, options = {}) => {
const uid = generateUidBasedOnHash(collectionPath);
if (!brunoConfig.ignore || brunoConfig.ignore.length === 0) {
// Forces default behavior for legacy collections
// 5 Feb 2024:
// bruno.json now supports an "ignore" field to specify which folders to ignore
// if the ignore field is not present, we default to ignoring node_modules and .git
// this is to maintain backwards compatibility with older collections
brunoConfig.ignore = ['node_modules', '.git'];
}

View File

@ -414,7 +414,15 @@ class Watcher {
const watcher = chokidar.watch(watchPath, {
ignoreInitial: false,
usePolling: watchPath.startsWith('\\\\') ? true : false,
ignored: (path) => ignores.some((s) => path.includes(s)),
ignored: (filepath) => {
const normalizedPath = filepath.replace(/\\/g, '/');
const relativePath = path.relative(watchPath, normalizedPath);
return ignores.some((ignorePattern) => {
const normalizedIgnorePattern = ignorePattern.replace(/\\/g, '/');
return relativePath === normalizedIgnorePattern || relativePath.startsWith(normalizedIgnorePattern);
});
},
persistent: true,
ignorePermissionErrors: true,
awaitWriteFinish: {