Skip to content

Commit f4d0fcf

Browse files
authored
Merge pull request #805 from dapphub/color-build-output
dapp: build: strip escape chars and colorize output
2 parents 28cb13f + db8bc56 commit f4d0fcf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/dapp/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Added
11+
12+
- The output from `dapp build` now uses color to differentiate warnings and errors
13+
1014
### Changed
1115

1216
- Dapp remappings ignores non-directories in `DAPP_LIB`

src/dapp/libexec/dapp/dapp-build

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ info() {
2727
echo >&2 "$FLAGS" "${0##*/}: $ARGS"
2828
}
2929

30+
colorize() {
31+
awk '{
32+
gsub("Warning:", "\033[1;33m&\033[0m");
33+
gsub(".*Error:", "\033[1;31m&\033[0m");
34+
print }'
35+
}
36+
3037
cd "$DAPP_ROOT"
3138

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

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

0 commit comments

Comments
 (0)