From c9dba4e240b3ef92dc65b3b1c16979b851f26275 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Wed, 6 Aug 2025 19:01:53 +1000 Subject: [PATCH] add trap to SIGTERM sass bg process --- serve | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/serve b/serve index 8b35a1a..b510ca1 100755 --- a/serve +++ b/serve @@ -15,6 +15,16 @@ SCSS_PATH="$WEBROOT/scss" 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 function watch_scss { # watch format "SCSS_PATH:OUT_PATH" @@ -37,8 +47,13 @@ function host { simple-http-server $args $@ -- "$WEBROOT" } +trap cleanup EXIT set -ueo pipefail set -x +# auto compile scss changes watch_scss & -hostwww +SASS_PID=$! + +# host dev server +host ${SRV_ARGS[@]}