diff options
Diffstat (limited to 'internal/watcher/watch.go')
| -rw-r--r-- | internal/watcher/watch.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/watcher/watch.go b/internal/watcher/watch.go new file mode 100644 index 0000000..95146ce --- /dev/null +++ b/internal/watcher/watch.go @@ -0,0 +1,26 @@ +package watcher + +import ( + "io/fs" + "path/filepath" + + "github.com/fsnotify/fsnotify" +) + +// watchTree recursively watches root and all of its subdirectories. +func watchTree( + w *fsnotify.Watcher, + root string, +) error { + return filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if !d.IsDir() { + return nil + } + + return w.Add(path) + }) +} |