2013-11-20 21:08:22 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2013-11-27 10:55:00 +00:00
|
|
|
autoload colors
|
|
|
|
colors
|
|
|
|
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
|
|
|
|
eval $COLOR='$fg_no_bold[${(L)COLOR}]'
|
|
|
|
eval BOLD_$COLOR='$fg_bold[${(L)COLOR}]'
|
|
|
|
done
|
|
|
|
eval RESET='$reset_color'
|
|
|
|
|
|
|
|
latestThread=0
|
2013-11-20 21:08:22 +00:00
|
|
|
relaunchCompilation() {
|
|
|
|
while read line; do
|
|
|
|
if (( $( print -- $line | grep '.cabal-sandbox' | wc -l) == 0 )); then
|
2013-11-27 10:55:00 +00:00
|
|
|
(($latestThread>0)) && \
|
|
|
|
(( $(ps x | awk "\$1 == $latestThread" | wc -l)>0 )) && {
|
|
|
|
print -- "\n${RED}STOPPED${RESET}"
|
|
|
|
kill $latestThread
|
|
|
|
}
|
|
|
|
print "${BLUE}$line${RESET}"
|
|
|
|
{ cabal install && \
|
|
|
|
./.cabal-sandbox/bin/test-holy-project } &
|
|
|
|
latestThread=$!
|
2013-11-20 21:08:22 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-12-04 12:35:31 +00:00
|
|
|
echo "First launch" | relaunchCompilation
|
2013-11-21 11:25:34 +00:00
|
|
|
case $(uname) in
|
|
|
|
Darwin)
|
|
|
|
# On mac OS X, use hobbes (cabal install hobbes)
|
|
|
|
# launch a cabal install and cabal test after each
|
|
|
|
# small haskell file modification
|
|
|
|
{hobbes "*.hs" | relaunchCompilation } &
|
|
|
|
hobbes "*.cabal" | relaunchCompilation
|
|
|
|
;;
|
|
|
|
*) # On other Unixes
|
2013-11-21 16:16:47 +00:00
|
|
|
tmp=$(date +"%s")
|
|
|
|
t=$tmp
|
2013-11-21 11:25:34 +00:00
|
|
|
while true; do
|
2013-11-27 10:55:00 +00:00
|
|
|
tmp=$(( $t - 1 ))
|
2013-11-21 16:16:47 +00:00
|
|
|
t=$(date +"%s")
|
2013-11-21 11:25:34 +00:00
|
|
|
for fic in {src,test}/**/*.hs(.) *.cabal; do
|
|
|
|
# note to use on OS X, use "stat -f %m $checkfile" instead
|
|
|
|
modtime=$(stat --printf %Y $fic)
|
2013-11-21 16:16:47 +00:00
|
|
|
(( $modtime > $tmp )) && print $fic
|
2013-11-21 11:25:34 +00:00
|
|
|
done
|
|
|
|
sleep 1
|
|
|
|
done | relaunchCompilation
|
|
|
|
;;
|
|
|
|
esac
|