return filepath.SkipDir instead of nil for excluded dir entries

This commit is contained in:
Gani Georgiev
2026-06-07 10:45:48 +03:00
parent 394a46f3a2
commit 3350ae651d
2 changed files with 11 additions and 4 deletions
+7 -2
View File
@@ -443,11 +443,16 @@ func (p *plugin) watchHooks() error {
//
// @todo replace once recursive watcher is added (https://github.com/fsnotify/fsnotify/issues/18)
dirsErr := filepath.WalkDir(watchDir, func(path string, entry fs.DirEntry, err error) error {
// skip access failures, hidden directories, node_modules, etc.
if err != nil || !entry.IsDir() || entry.Name() == "node_modules" || strings.HasPrefix(entry.Name(), ".") {
// ignore access failures and non-dir entries
if err != nil || !entry.IsDir() {
return nil
}
// skip traversing hidden directories and node_modules
if strings.HasPrefix(entry.Name(), ".") || entry.Name() == "node_modules" {
return filepath.SkipDir
}
return watcher.Add(path)
})
if dirsErr != nil {