-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·57 lines (47 loc) · 1012 Bytes
/
dev.sh
File metadata and controls
executable file
·57 lines (47 loc) · 1012 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# Usage: ./dev.sh [-p PORT]
CLI_PORT=""
while getopts "p:" opt; do
case $opt in
p)
CLI_PORT="$OPTARG"
;;
*) echo "Usage: $0 [-p backend_port]" >&2; exit 1 ;;
esac
done
# Load env vars (R2 credentials, etc.) if present
if [ -f .env ]; then
set -a; source .env; set +a
fi
# Load worktree-specific port assignments (PORT, FRONTEND_PORT)
if [ -f .env.local ]; then
set -a; source .env.local; set +a
fi
if [ -n "$CLI_PORT" ]; then
export PORT="$CLI_PORT"
export FRONTEND_PORT=$((PORT + 1))
fi
export PORT="${PORT:-5111}"
export FRONTEND_PORT="${FRONTEND_PORT:-$((PORT + 1))}"
PIDS=()
cleanup() {
if [ "${#PIDS[@]}" -gt 0 ]; then
kill "${PIDS[@]}" 2>/dev/null || true
fi
}
trap cleanup EXIT
# Backend (bun --watch)
cd backend
bun run dev 2>&1 | sed 's/^/[BE] /' &
BE_PID=$!
PIDS+=("$BE_PID")
cd ..
# Frontend (vite dev)
cd frontend
bun run dev 2>&1 | sed 's/^/[FE] /' &
FE_PID=$!
PIDS+=("$FE_PID")
cd ..
wait