add trap to SIGTERM sass bg process

This commit is contained in:
Emile Clark-Boman 2025-08-06 19:01:53 +10:00
parent f4f8e15bf1
commit c9dba4e240

17
serve
View file

@ -15,6 +15,16 @@ SCSS_PATH="$WEBROOT/scss"
CSS_PATH="$WEBROOT/css" CSS_PATH="$WEBROOT/css"
# ========================= # # ========================= #
# ===== Local State ===== #
SASS_PID=
# ======================= #
function cleanup {
if [[ -n "$SASS_PID" ]]; then
kill "$SASS_PID"
fi
}
# Watch .sass/.scss files and compile on change # Watch .sass/.scss files and compile on change
function watch_scss { function watch_scss {
# watch format "SCSS_PATH:OUT_PATH" # watch format "SCSS_PATH:OUT_PATH"
@ -37,8 +47,13 @@ function host {
simple-http-server $args $@ -- "$WEBROOT" simple-http-server $args $@ -- "$WEBROOT"
} }
trap cleanup EXIT
set -ueo pipefail set -ueo pipefail
set -x set -x
# auto compile scss changes
watch_scss & watch_scss &
hostwww SASS_PID=$!
# host dev server
host ${SRV_ARGS[@]}