-
Notifications
You must be signed in to change notification settings - Fork 1
/
runClone.sh
executable file
·45 lines (37 loc) · 916 Bytes
/
runClone.sh
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
#!/bin/bash
SOURCE_DIR="../teaching-website"
DEST_DIR="./"
# Function to run rsync
run_rsync() {
rsync -av --delete \
--exclude='runClone.sh' \
--exclude='.git' \
--exclude='node_modules' \
--exclude='scripts' \
--exclude='build' \
--exclude='.docusaurus' \
--exclude='.env' \
"$SOURCE_DIR/" "$DEST_DIR"
}
# Function to start Docusaurus dev server
start_docusaurus() {
SITE=gbsl PORT=3001 yarn run start &
DOCUSAURUS_PID=$!
}
# Function to cleanup and exit
cleanup_and_exit() {
echo "Stopping Docusaurus dev server and sync watch..."
kill $DOCUSAURUS_PID
exit 0
}
# Set up trap to handle Ctrl+C
trap cleanup_and_exit INT
# Start Docusaurus dev server
start_docusaurus
# Initial sync
run_rsync
# Monitor for changes and sync
fswatch -o "$SOURCE_DIR" | while read f; do
echo "Change detected in $f"
run_rsync
done