-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-build.sh
executable file
·33 lines (25 loc) · 1.06 KB
/
auto-build.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
#!/bin/bash
# Folder to monitor
FOLDER_TO_WATCH="/Users/naresh/Downloads/phd/grad-notes/source"
# Python script to run when a change is detected
PYTHON_FILE="/Users/naresh/Downloads/phd/grad-notes/build.py"
# File or folder to ignore (you can add more if needed)
IGNORE_PATTERN="/Users/naresh/Downloads/phd/grad-notes/source/_build"
# Continuously monitor the folder, running the Python script once per detected change
while true; do
# Wait for the first change event, then run the Python script
fswatch -1 "$FOLDER_TO_WATCH" | while read event; do
# Check if the event matches the ignored pattern
if [[ "$event" == *"$IGNORE_PATTERN"* ]]; then
echo "Change in ignored file/folder: $event, skipping..."
continue
fi
echo "Change detected: $event"
# Run the Python script only once per change
python3 "$PYTHON_FILE"
# Break to stop monitoring temporarily
break
done
# Optional: wait 5 seconds before starting to monitor again
sleep 10
done