diff --git a/gitignore.go b/gitignore.go index 99691a8..1a8e29e 100644 --- a/gitignore.go +++ b/gitignore.go @@ -12,7 +12,7 @@ var GitIgnoreSupported = false func initGitignore() { if _, err := exec.LookPath("git"); err != nil { - logger.Printf("gitignore not supported: %v", err) + logger.Printf("gitignore not supported: %v\n", err) } else { GitIgnoreSupported = true } diff --git a/main.go b/main.go index 6d1fc77..b484be6 100644 --- a/main.go +++ b/main.go @@ -75,13 +75,15 @@ func main() { // Runs the command and re-starts it on file changes. func run(cmd string, args ...string) { - // TODO: support other filter options? - if !GitIgnoreSupported { - die("error: gitignore filter not supported") + filter := func(_ FsEvent) (bool, error) { + return false, nil } - filter := func(event FsEvent) (bool, error) { - return GitIgnored(event.Path) + if GitIgnoreSupported { + logger.Printf("using .gitignore filter") + filter = func(event FsEvent) (bool, error) { + return GitIgnored(event.Path) + } } watcher, err := NewWatcher(filter) @@ -96,7 +98,7 @@ func run(cmd string, args ...string) { handle := func(e WatcherEvent) error { if e.Error != nil { - logger.Printf("watcher error: %v", e.Error) + logger.Printf("watcher error: %v\n", e.Error) return nil } if err = stopProcess(proc); err != nil { diff --git a/main_nonwindows.go b/main_nonwindows.go index 09f9937..1af8a5a 100644 --- a/main_nonwindows.go +++ b/main_nonwindows.go @@ -23,14 +23,14 @@ func stopProcess(proc *exec.Cmd) error { pid := proc.Process.Pid if err := syscall.Kill(-pid, syscall.SIGINT); err != nil { - logger.Printf("failed to send SIGINT to %s: %s", path.Base(proc.Path), err.Error()) + logger.Printf("failed to send SIGINT to %s: %s\n", path.Base(proc.Path), err.Error()) } else { // If the sigint worked then give it a moment time.Sleep(200 * time.Millisecond) } if err := syscall.Kill(-pid, syscall.SIGKILL); err != nil { - return fmt.Errorf("failed to kill %s: %s", path.Base(proc.Path), err.Error()) + return fmt.Errorf("failed to kill %s: %s\n", path.Base(proc.Path), err.Error()) } // This will error with 'signal: killed' or 'exit status 1' if we killed diff --git a/watcher.go b/watcher.go index 4282672..f3799f8 100644 --- a/watcher.go +++ b/watcher.go @@ -163,9 +163,9 @@ func (w *watcherImpl) start() { skip, err := w.filter(fsEvent) if err != nil { logger.Printf( - "watcher filter error: event=%v, error=%v", fsEvent, err) + "watcher filter error: event=%v, error=%v\n", fsEvent, err) } else if skip { - logger.Printf("watcher filter: ignoring event %v", fsEvent) + logger.Printf("watcher filter: ignoring event %v\n", fsEvent) break } w.events <- WatcherEvent{