From e1535c74cc494dce85ea5c2e8a25665bed444217 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 5 Sep 2020 02:55:06 +0200 Subject: [PATCH] Add 'make watch' (#12636) * Add 'make watch' This combines frontend and backend watch into a single command that runs them in parallel on on SIGINT terminates both. Termination is not super-clean but I guess it does not have to. * move to tools/, trap more signals, remove gnu-specific flag * simplify Co-authored-by: techknowlogick --- Makefile | 5 +++++ docs/content/doc/advanced/hacking-on-gitea.en-us.md | 8 ++------ tools/watch.sh | 8 ++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 tools/watch.sh diff --git a/Makefile b/Makefile index f8e3668de1..bdf3855b27 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,7 @@ help: @echo " - build build everything" @echo " - frontend build frontend files" @echo " - backend build backend files" + @echo " - watch watch everything and continuously rebuild" @echo " - watch-frontend watch frontend files and continuously rebuild" @echo " - watch-backend watch backend files and continuously rebuild" @echo " - clean delete backend and integration files" @@ -316,6 +317,10 @@ lint-frontend: node_modules .PHONY: lint-backend lint-backend: golangci-lint revive vet +.PHONY: watch +watch: + bash tools/watch.sh + .PHONY: watch-frontend watch-frontend: node-check $(FOMANTIC_DEST) node_modules rm -rf $(WEBPACK_DEST_ENTRIES) diff --git a/docs/content/doc/advanced/hacking-on-gitea.en-us.md b/docs/content/doc/advanced/hacking-on-gitea.en-us.md index 0c8ab419e4..1d2702a5e8 100644 --- a/docs/content/doc/advanced/hacking-on-gitea.en-us.md +++ b/docs/content/doc/advanced/hacking-on-gitea.en-us.md @@ -94,14 +94,10 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https: ## Building continuously -Both the `frontend` and `backend` targets can be ran continuously when source files change: +To run and continously rebuild when source files change: ````bash -# in your first terminal -make watch-backend - -# in your second terminal -make watch-frontend +make watch ```` On macOS, watching all backend source files may hit the default open files limit which can be increased via `ulimit -n 12288` for the current shell or in your shell startup file for all future shells. diff --git a/tools/watch.sh b/tools/watch.sh new file mode 100644 index 0000000000..61e3dc40a2 --- /dev/null +++ b/tools/watch.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +make watch-frontend & +make watch-backend & + +trap 'kill $(jobs -p)' EXIT +wait