Last active
March 15, 2020 21:16
-
-
Save felixSchl/167678b0c76539138cac82ebba1b02cb to your computer and use it in GitHub Desktop.
Emacs 'M-x compile' compatible 'purs compile' output (spago only)
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
#!/bin/bash | |
# compilation-mode compatible spago build output | |
set -eo pipefail | |
root=$(git rev-parse --show-toplevel) | |
PATH=$root/node_modules/.bin:$PATH | |
output=$(spago 3>&2 2>&1 1>&3 --quiet build -u --json-errors || { :; }) | |
n_errors=$(jq <<< "$output" '.errors | length') | |
n_warnings=$(jq <<< "$output" '.warnings | length') | |
if [[ "$n_warnings" -gt 0 ]]; then | |
echo "${n_warnings} warning(s):" | |
jq --arg root "$root" -r <<< "$output" '.warnings[] | "Warning " + $root + "/" + .filename + " " + (.position.startLine|tostring) + ": " + .message' | |
fi | |
if [[ "$n_errors" -gt 0 ]]; then | |
echo "${n_errors} error(s):" | |
jq --arg root "$root" -r <<< "$output" '.errors[] | "Error " + $root + "/" + .filename + " " + (.position.startLine|tostring) + ": " + .message' | |
exit 1 | |
fi | |
if [[ "$1" == test ]]; then | |
spago test | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment