all repos — erl @ d29d0816680a343ee47c40fa9ace8d80862ac412

Execute Reload Loop

feat: apply ignores from .gitignore/.ignore files

Alan Pearce
commit

d29d0816680a343ee47c40fa9ace8d80862ac412

parent

a52be32962b55478c31d6f4e1139e4ab4b140100

1 file changed, 18 insertions(+), 3 deletions(-)

changed files
M main.gomain.go
@@ -3,6 +3,7 @@
import ( "context" "errors" + "fmt" "io" "log" "os"
@@ -17,6 +18,7 @@ "github.com/fsnotify/fsnotify"
"github.com/jessevdk/go-flags" "alin.ovh/erl/command" + "alin.ovh/erl/ignore" "alin.ovh/erl/state" "alin.ovh/erl/watcher" )
@@ -127,11 +129,10 @@ args = slices.Insert(args, 0, "run")
} } - watcher, err := watcher.New() + wd, err := os.Getwd() if err != nil { - log.Fatal(err) + log.Fatalf("failed to get working directory: %v", err) } - defer watcher.Close() ctx, cancel := signal.NotifyContext( context.Background(),
@@ -140,6 +141,20 @@ syscall.SIGHUP,
syscall.SIGTERM, ) defer cancel() + + filter := ignore.New(wd) + err = filter.ReadIgnoreFiles(ctx) + if err != nil { + panic(fmt.Sprintf("failed to read ignore files: %v", err)) + } + + watcher, err := watcher.New(watcher.Options{ + Filter: *filter, + }) + if err != nil { + panic(fmt.Sprintf("failed to create watcher: %v", err)) + } + defer watcher.Close() copts := command.Options{} if opts.Quiet {