Skip to content

Commit

Permalink
fix: watcher ignore list improvements (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza authored Mar 4, 2025
1 parent aea8b36 commit 1eecdb0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/program/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,22 @@ func StartWatcher(dir string, ch chan tea.Msg, filter []string) tea.Cmd {
w.FilterOps(watcher.Write, watcher.Remove)

ignored := []string{
"node_modules/",
".build/",
".git/",
"node_modules",
}

w.AddFilterHook(func(info os.FileInfo, fullPath string) error {
for _, v := range ignored {
if strings.Contains(fullPath, v) {
// Skip if any directory component is hidden or is in the ignored list
pathParts := strings.Split(filepath.Clean(fullPath), string(filepath.Separator))
for _, part := range pathParts {
if strings.HasPrefix(part, ".") {
return watcher.ErrSkip
}

for _, v := range ignored {
if strings.Contains(part, v) {
return watcher.ErrSkip
}
}
}

// If there is a filter set then only watch these files
Expand Down

0 comments on commit 1eecdb0

Please sign in to comment.