Skip to content

Commit

Permalink
vm: mount: inotify: ignore node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
abiosoft committed Mar 25, 2023
1 parent 85f8c19 commit ad6ef96
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions daemon/process/inotify/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,29 @@ func (f *inotifyProcess) watchFiles(ctx context.Context) error {
}
}

var omittedDirs = map[string]struct{}{
"node_modules": {},
}

func doWatch(dirs []string, fileMap map[string]time.Time, changed chan<- modTime) error {
for _, dir := range dirs {
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return nil
}

// skip hidden dirs
if strings.HasPrefix(d.Name(), ".") && d.IsDir() {
return fs.SkipDir
}

// do nothing for directories
if d.IsDir() {
// avoid traversing hidden dirs
if strings.HasPrefix(d.Name(), ".") {
return fs.SkipDir
}

// avoid travesing omitted dirs
if _, ok := omittedDirs[d.Name()]; ok {
return fs.SkipDir
}

// do nothing and continue traversing other directories
return nil
}

Expand Down

0 comments on commit ad6ef96

Please sign in to comment.