summaryrefslogtreecommitdiff
path: root/justfile
blob: 2b85db7b495ce9acb07e471bf838aee9f9583365 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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