Last active
February 2, 2021 02:36
-
-
Save mattpolzin/8cb2ec0158c9748a36838f0d034613ba to your computer and use it in GitHub Desktop.
Little script for watching an Idris source directory and building changes.
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
#!/usr/bin/env sh | |
if [[ "$1" == "" ]]; then | |
${SHELL:-bash} $(pwd)/watch_and_learn.sh watch | |
exit 0 | |
fi | |
function watch() { | |
clear | |
echo "waiting..." | |
fswatch -E --exclude='(.+\.idr~)|(.+\.swp.*)' -ro ./ | xargs -n1 ./watch_and_learn.sh | |
} | |
function learn() { | |
build_out="$(idris2 --build *.ipkg)" | |
status="$?" | |
clear | |
if [[ "$status" == "0" ]]; then | |
echo "All good." | |
else | |
echo "$build_out" | |
fi | |
} | |
if [[ "$(which fswatch)" == "" ]]; then | |
echo "fswatch not installed." | |
echo "" | |
exit 1 | |
fi | |
if [[ "$1" == 'watch' ]]; then | |
watch | |
else | |
learn | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment