1#!/bin/sh
2
3if ! command -v fourmolu 1>/dev/null; then
4 echo "error: fourmolu is not installed" 1>&2
5 exit 1
6fi
7
8out=$(git diff --cached --name-only app/ src/ test/ | xargs -r fourmolu -q --mode check 2>&1)
9if [ $? -ne 0 ]; then
10 printf "The following files need to be formated with 'fourmolu':\n\n" 1>&2
11 printf "%s\n" "${out}" | awk '/\.hs$/ { printf("\t%s\n", $0) }' 1>&2
12 exit 1
13fi