Last active
December 17, 2015 06:19
-
-
Save Dav1dde/5564367 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "[Compile]" | |
OUT=$(dub build --rdmd 2>&1) | |
bin/rcd 1>/dev/null 2>&1 & | |
PID=$! | |
echo " [Ready]" | |
inotifywait -m ./rcd -r 2>/dev/null | while read -r dir event name; do | |
if [ "$event" == "MODIFY" -o "$event" == "MOVED_TO" ]; then | |
echo $name | grep -P "\.dt?$" > /dev/null | |
if [ $? -eq 0 ]; then | |
echo "[Compile]" | |
OUT=$(dub build --rdmd 2>&1) | |
if [ $? -eq 0 ]; then | |
echo " [Reload]" | |
kill $PID | |
if [ $? -ne 0 ]; then | |
echo "[Hard Kill]" | |
kill -9 $PID | |
fi | |
sleep 1s | |
bin/rcd 1>/dev/null & | |
PID=$! | |
echo " [Ready]" | |
else | |
echo " [Build Failed]" | |
echo $OUT | |
echo "" | |
fi | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment