Skip to content

Commit

Permalink
Add excludes feature and remove 10k file watcher hard limit
Browse files Browse the repository at this point in the history
Note: I tried watching node_modules, it will crash no matter how
buffered your watcher is
  • Loading branch information
Niklas Hanft committed Nov 20, 2024
1 parent 0e6866c commit c57e949
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .nfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pod:

watch:
- pattern: "./**/*.php"
excludes:
- "node_modules"
hooks:
- "yarn run build"
- pattern: "*.go"
6 changes: 1 addition & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var rootCmd = &cobra.Command{
for _, watchConfig := range config.WatchConfig {

err = doublestar.GlobWalk(fsys, watchConfig.Pattern, func(path string, d fs.DirEntry) error {
for _, exclude := range v1.GlobalExclude {
for _, exclude := range watchConfig.Excludes {
if strings.Contains(path, exclude) {
return doublestar.SkipDir
}
Expand All @@ -64,10 +64,6 @@ var rootCmd = &cobra.Command{
slices.Sort(filesToWatch)
slices.Compact(filesToWatch)

if len(filesToWatch) >= 10000 {
panic("Watching too many files")
}

fmt.Printf("Setup watchers for %d files.\n", len(filesToWatch))

for _, path := range filesToWatch {
Expand Down
5 changes: 3 additions & 2 deletions internal/config/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
var GlobalExclude = []string{"node_modules", ".git", ".nuxt", "test"}

type NfsWatchConfig struct {
Pattern string
Hooks []string
Pattern string
Hooks []string
Excludes []string
}

type NfsPodConfig struct {
Expand Down

0 comments on commit c57e949

Please sign in to comment.