Skip to content

Commit

Permalink
dapp: build: strip escape chars and colorize output
Browse files Browse the repository at this point in the history
- strips '\' chars from the output
- colors errors in red, and warnings in yellow
  • Loading branch information
d-xo committed Sep 21, 2021
1 parent 583330c commit 8728da4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dapp/libexec/dapp/dapp-build
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ info() {
echo >&2 "$FLAGS" "${0##*/}: $ARGS"
}

colorize() {
awk '{
gsub("Warning:", "\033[1;33m&\033[0m");
gsub(".*Error:", "\033[1;31m&\033[0m");
print }'
}

cd "$DAPP_ROOT"

# use a custom path if DAPP_SOLC is set
Expand Down Expand Up @@ -68,7 +75,7 @@ if [[ -z "$DAPP_BUILD_LEGACY" && -z "$DAPP_BUILD_EXTRACT" ]]; then

# pipe errors to stderr
jq -r 'if .errors then .errors | map(."formattedMessage") | @sh else empty end' "$DAPP_JSON" \
| sed -e "s/' //g" -e "s/'//g" 1>&2
| sed -e "s/' //g" -e "s/'//g" -e 's/\\\(.\)\\/\1 /g' | colorize 1>&2
# if sources is empty, the compilation failed
[[ $(jq -r '.sources' "$DAPP_JSON") = "null" || $(jq -r '.sources' "$DAPP_JSON") = {} ]] && exit 1 || exit 0

Expand Down

0 comments on commit 8728da4

Please # to comment.