Idris-dev/stylize.sh

41 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2016-10-04 04:54:19 +03:00
set -e
if [ -n "$TRAVIS" ];
then
mkdir -p ~/.local/bin
2017-01-16 12:13:52 +03:00
export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:$PATH
curl --retry 3 -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
2017-01-16 13:32:04 +03:00
stack config set system-ghc --global true
2017-01-16 12:13:52 +03:00
stack install --resolver "lts-$STACKVER" stylish-haskell --no-terminal
2016-10-04 04:54:19 +03:00
fi
2017-04-04 11:40:16 +03:00
command -v stylish-haskell >/dev/null 2>&1 || { echo "Could not find stylish-haskell. Aborting." >&2; exit 1; }
2016-10-04 04:54:19 +03:00
find . -name \*.hs -and \( -not \( -name Setup.hs -or -path ./.cabal-sandbox/\* -or -path ./dist/\* \) \) | xargs stylish-haskell -i > stylish-out 2>&1
2016-10-04 04:54:19 +03:00
# It doesn't do exit codes properly, so we just check if it outputted anything.
if [ -s stylish-out ];
then
echo "Stylish-haskell reported an error :("
cat stylish-out
exit 1
2016-10-04 04:54:19 +03:00
fi
rm stylish-out
if git status --porcelain|grep .; # true if there was any output
then
echo "Git tree is dirty after stylizing.";
if [ -n "$TRAVIS" ];
then
echo "Since we're on Travis, this is a build failure."
echo "Run ./stylize.sh to stylize your tree and push the changes."
exit 1
fi
2016-10-04 04:54:19 +03:00
else
echo "Stylish didn't change anything :)"
2016-10-04 04:54:19 +03:00
exit 0;
fi