saq
A toolchain-agnostic live reload tool that supports automatic reloading of the
browser when a file is changed.
Basic Example
saq \
-s http://localhost:8081 \
-t localhost:8080 \
-i ./... \
-x .git \
--gitignoreFile .gitignore \
-- bash -c 'make build && ./build/main --http localhost:8081'
# or equivalently
saq -- bash -c 'make build && ./build/main --http localhost:8081'
Note: go run
does not propagate signals to the child process, so you
should not use go run
with saq
. See https://github.com/golang/go/issues/40467.
How it works
saq
acts as a reverse proxy. It works as follows:
- It injects a script into the HTML response that
fetch
es an endpoint that
blocks until a file change is detected.
- When a file change is detected, the server process is restarted, which
saq
then tries to connect by sending a HEAD
request to the server.
- Once the server is up, the browser is reloaded.
saq
only works on Linux due to its dependency on illarion/gonotify.
Help
Usage: ./saq [flags...] argv...
Flags:
-x, --exclude strings exclude directories/paths/globs (default [./.git,./.direnv,./vendor,*.tmpl])
--generated-check string command to check if a file is generated, executes $SHELL or /bin/sh otherwise (default "[[ $FILE == *.go ]] && grep \"^// Code generated by\" \"$FILE\"")
--gitignore string gitignore file to use, empty to disable (default ".gitignore")
-i, --include string include directory (default ".")
-s, --source string source URL of the upstream server (default "http://localhost:8081")
-t, --target string target address to listen on (default "localhost:8080")
-v, --verbose verbose logging
Who made the name?
@FreezingSnail