From 334a923d791c91b83c3d2666c1a51468e35ce658 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 30 Jan 2024 11:09:18 +0100 Subject: [PATCH] add watch script --- README.md | 10 ++++------ scripts/watch.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100755 scripts/watch.sh diff --git a/README.md b/README.md index 962ed49..5db88b5 100644 --- a/README.md +++ b/README.md @@ -11,16 +11,14 @@ The Ibis is a [bird which is related to the Egyptian god of knowledge and scienc You need to install [cargo](https://rustup.rs/) and [trunk](https://trunkrs.dev). Then run the following commands in separate terminals: ``` -# start backend, with separate target folder to avoid rebuilds from arch change -cargo run --target-dir target/backend -# or with automatic rebuild on changes using cargo-watch -CARGO_TARGET_DIR=target/backend cargo watch -c -x run +# start backend +cargo run -# start frontend, automatic rebuild on changes +# start frontend with automatic rebuild on changes trunk serve -w src/frontend/ ``` -Then open the site at [127.0.0.1:8080](http://127.0.0.1:8080/). +Then open the site at [127.0.0.1:8080](http://127.0.0.1:8080/). Alternatively you can run `./scripts/watch.sh` to rebuild backend and frontend automatically on code changes (requires [cargo-watch](https://crates.io/crates/cargo-watch)). ## License diff --git a/scripts/watch.sh b/scripts/watch.sh new file mode 100755 index 0000000..88bcbaf --- /dev/null +++ b/scripts/watch.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# run processes in parallel +# https://stackoverflow.com/a/52033580 +(trap 'kill 0' SIGINT; + # start frontend + trunk serve -w src/frontend/ & + # # start backend, with separate target folder to avoid rebuilds from arch change + CARGO_TARGET_DIR=target/backend cargo watch -c -x run +)