summaryrefslogtreecommitdiff
path: root/justfile
diff options
context:
space:
mode:
Diffstat (limited to 'justfile')
-rw-r--r--justfile33
1 files changed, 33 insertions, 0 deletions
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..2b85db7
--- /dev/null
+++ b/justfile
@@ -0,0 +1,33 @@
+run directory:
+ cd '{{directory}}' && gleam run
+
+watch directory:
+ #!/usr/bin/env sh
+
+ cd '{{directory}}'
+
+ start_gleam() {
+ gleam run &
+ }
+
+ stop_beam() {
+ BEAM_PID=$(pgrep -f beam.smp)
+
+ if [ -n "${BEAM_PID}" ]; then
+ kill "${BEAM_PID}"
+ wait "${BEAM_PID}" 2>/dev/null
+ fi
+ }
+
+ if ! command -v inotifywait >/dev/null; then
+ echo "error: inotifywait could not be found. please install inotify-tools."
+ exit 1
+ fi
+
+ start_gleam
+
+ while inotifywait -r -e modify,create,delete,move src; do
+ stop_beam
+ sleep 1
+ start_gleam
+ done