Run a command when watched files change.
Please report any issues you encounter.
Run a command when watched files change.
Usage:
onchange [options] command [args]
Options:
-c clear screen before each execution
-d int
ignore too fast reruns within time limit (ms) (default 10)
-dry
show a list of watched paths and exit
-f string
file pattern regular expression (default ".+")
-i run command immediately (don't wait for first event)
-k kill long-running command on new events
-p int
file poll interval (ms) (default 100)
-r watch directory recursively
-w string
directory to search from (default ".")
Watch all go files recursively from current directory and run go build
on changes:
onchange -c -i -f \.go$ -r go build
Run a built binary after it has been built, and notify when build is complete:
onchange -i -r bash -c "go build && notify-send go 'Build complete' && ./foobin"
$ go install github.com/stigok/go-onchange
Make sure you have $GOPATH/bin
added to your $PATH
.
$ go build
The underlying library used to watch files is written by Benjamin Radovsky (BSD 3-Clause "New" or "Revised" License). Read the full license text in pkg/github.com/radovskyb/watcher/LICENSE.