on 385dcbf help sign in
Idris-dev/stylize.sh
40 lines 1.2 kB history raw
1#!/usr/bin/env bash
3set -e
5if [ -n "$TRAVIS" ];
6then
7 mkdir -p ~/.local/bin
8 export PATH=$HOME/.local/bin:/opt/ghc/$GHCVER/bin:$PATH
9 curl --retry 3 -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
10 stack config set system-ghc --global true
11 stack install --resolver "lts-$STACKVER" stylish-haskell --no-terminal
12fi
14command -v stylish-haskell >/dev/null 2>&1 || { echo "Could not find stylish-haskell. Aborting." >&2; exit 1; }
16find . -name \*.hs -and \( -not \( -name Setup.hs -or -path ./.cabal-sandbox/\* -or -path ./dist/\* \) \) | xargs stylish-haskell -i > stylish-out 2>&1
18# It doesn't do exit codes properly, so we just check if it outputted anything.
19if [ -s stylish-out ];
20then
21 echo "Stylish-haskell reported an error :("
22 cat stylish-out
23 exit 1
24fi
26rm stylish-out
28if git status --porcelain|grep .; # true if there was any output
29then
30 echo "Git tree is dirty after stylizing.";
31 if [ -n "$TRAVIS" ];
32 then
33 echo "Since we're on Travis, this is a build failure."
34 echo "Run ./stylize.sh to stylize your tree and push the changes."
35 exit 1
36 fi
37else
38 echo "Stylish didn't change anything :)"
39 exit 0;
40fi