-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch-react-mac.sh
More file actions
51 lines (44 loc) · 1.27 KB
/
watch-react-mac.sh
File metadata and controls
51 lines (44 loc) · 1.27 KB
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
#!/usr/bin/env zsh
# Void React Watch Script
# Purpose: Start React watch mode for development
echo "========================================"
echo " Void React Watch"
echo "========================================"
echo ""
# Step 1: Verify Node.js version
echo "[1/3] Verifying Node.js version..."
NODE_VERSION=$(node --version 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo "Error: Node.js not found. Please install Node.js v20.18.2 via 'sudo n 20.18.2'"
exit 1
fi
REQUIRED="v20.18.2"
if [[ "$NODE_VERSION" != "$REQUIRED" ]]; then
echo "Warning: Current Node.js is $NODE_VERSION, expected $REQUIRED"
echo "Switching to Node.js $REQUIRED via n..."
sudo n 20.18.2
if [[ $? -ne 0 ]]; then
echo "Error: Node.js version switch failed"
exit 1
fi
fi
NODE_VERSION=$(node --version)
echo "Success: Current Node.js version: $NODE_VERSION"
echo ""
# Step 2: Check dependencies
echo "[2/3] Checking node_modules..."
if [[ ! -d "node_modules" ]]; then
echo "Installing dependencies..."
npm install
if [[ $? -ne 0 ]]; then
echo "Error: npm install failed"
exit 1
fi
fi
echo "Success: Dependencies ready"
echo ""
# Step 3: Start React watch
echo "[3/3] Starting React watch..."
echo "Press Ctrl+C to stop"
echo ""
npm run watchreact