Skip to content

Commit c4fa370

Browse files
committed
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.
1 parent 66843f2 commit c4fa370

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ help:
155155
@echo " - build build everything"
156156
@echo " - frontend build frontend files"
157157
@echo " - backend build backend files"
158+
@echo " - watch watch everything and continuously rebuild"
158159
@echo " - watch-frontend watch frontend files and continuously rebuild"
159160
@echo " - watch-backend watch backend files and continuously rebuild"
160161
@echo " - clean delete backend and integration files"
@@ -314,6 +315,10 @@ lint-frontend: node_modules
314315
.PHONY: lint-backend
315316
lint-backend: golangci-lint revive vet
316317

318+
.PHONY: watch
319+
watch:
320+
bash build/watch.sh
321+
317322
.PHONY: watch-frontend
318323
watch-frontend: node-check $(FOMANTIC_DEST) node_modules
319324
rm -rf $(WEBPACK_DEST_ENTRIES)

build/watch.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
trap "kill 0" SIGINT
4+
5+
make --no-print-directory watch-frontend &
6+
PIDS+="$! ";
7+
make --no-print-directory watch-backend &
8+
PIDS+="$!";
9+
10+
trap "kill ${PIDS[*]}" SIGINT
11+
wait $PIDS

docs/content/doc/advanced/hacking-on-gitea.en-us.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,10 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https:
9797

9898
## Building continuously
9999

100-
Both the `frontend` and `backend` targets can be ran continuously when source files change:
100+
To run and continously rebuild when source files change:
101101

102102
````bash
103-
# in your first terminal
104-
make watch-backend
105-
106-
# in your second terminal
107-
make watch-frontend
103+
make watch
108104
````
109105

110106
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.

0 commit comments

Comments
 (0)