diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go old mode 100644 new mode 100755 index 49e3426..6dde355 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -3,10 +3,11 @@ package watcher import ( "github.com/fsnotify/fsnotify" "os" + "os/signal" "path/filepath" "squish/internal/utils" - "squish/pkg/esbuild" + "syscall" ) type Watcher struct { @@ -64,6 +65,16 @@ func (w *Watcher) Watch() error { return err } + // Setup signal handling for graceful shutdown + signals := make(chan os.Signal, 1) + signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) + + go func() { + <-signals + utils.Log("Received interrupt signal, shutting down watcher...") + close(done) + }() + utils.Log("Watching for changes in", w.srcDir) <-done return nil