Commit
Author: Kevin Schoon [me@kevinschoon.com]
Hash: fd006cce839a07757258d53d524a637a46888417
Timestamp: Tue, 24 May 2022 04:27:26 +0000 (2 years ago)

+21 -0 +/-2 browse
add inotifywait build script
1diff --git a/Makefile b/Makefile
2index fdc1100..d72b810 100644
3--- a/Makefile
4+++ b/Makefile
5 @@ -8,3 +8,6 @@ bin:
6
7 clean:
8 [[ -d bin ]] && rm -r bin
9+
10+ watch:
11+ ./watch.sh "hare build -o bin/hierarchy"
12 diff --git a/watch.sh b/watch.sh
13new file mode 100755
14index 0000000..9a4dd44
15--- /dev/null
16+++ b/watch.sh
17 @@ -0,0 +1,18 @@
18+ #!/bin/sh
19+
20+ BUILD_CMD="$1"
21+
22+ _do_build() {
23+ $BUILD_CMD && {
24+ echo -e "\033[32;1;4mSuccess\033[0m"
25+ } || {
26+ echo -e "\033[31;1;4mFailure\033[0m"
27+ }
28+ }
29+
30+ _do_build
31+ inotifywait -m -e close_write,moved_to --include '.*ha$' --format %e/%f . | \
32+ while IFS=/ read -r events file; do
33+ echo "file $file modified, rebuilding"
34+ _do_build
35+ done