Add first cut at a pool

This commit is contained in:
2026-01-01 15:43:49 -06:00
parent 8722062f4a
commit f504576f3e
6 changed files with 232 additions and 43 deletions

View File

@@ -1,12 +1,32 @@
package main
import (
"github.com/fsnotify/fsnotify"
"log"
"os"
"path/filepath"
"strings"
"github.com/fsnotify/fsnotify"
)
// shouldIgnore returns true for paths that should not trigger rebuilds
func shouldIgnore(path string) bool {
// Ignore build output and dependencies
ignoreDirs := []string{"/dist/", "/node_modules/", "/.git/"}
for _, dir := range ignoreDirs {
if strings.Contains(path, dir) {
return true
}
}
// Also ignore if path ends with these directories
for _, dir := range []string{"/dist", "/node_modules", "/.git"} {
if strings.HasSuffix(path, dir) {
return true
}
}
return false
}
func watchFiles(dir string, changes chan<- FileChange) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
@@ -14,12 +34,15 @@ func watchFiles(dir string, changes chan<- FileChange) {
}
defer watcher.Close()
// Add all directories recursively
// Add all directories recursively (except ignored ones)
err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
if shouldIgnore(path) {
return filepath.SkipDir
}
err = watcher.Add(path)
if err != nil {
log.Printf("Error watching %s: %v\n", path, err)
@@ -38,6 +61,11 @@ func watchFiles(dir string, changes chan<- FileChange) {
return
}
// Skip ignored paths
if shouldIgnore(event.Name) {
continue
}
// Handle different types of events
var operation string
switch {