https://github.com/stigok/go-onchange
Run a command when watched files change. (work in progress)
https://github.com/stigok/go-onchange
command-runner golang watcher
Last synced: 9 months ago
JSON representation
Run a command when watched files change. (work in progress)
- Host: GitHub
- URL: https://github.com/stigok/go-onchange
- Owner: stigok
- Created: 2019-09-25T11:10:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-07T14:06:24.000Z (over 6 years ago)
- Last Synced: 2025-08-31T13:38:25.277Z (10 months ago)
- Topics: command-runner, golang, watcher
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-onchange
Run a command when watched files change.
Please report any issues you encounter.
## Usage
```
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 ".")
```
### Examples
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"
```
## Install
```
$ go install github.com/stigok/go-onchange
```
Make sure you have `$GOPATH/bin` added to your `$PATH`.
## Building
```
$ go build
```
## License
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]().