Skip to content

Commit 3458afe

Browse files
authored
Merge pull request #831 from axone-protocol/build/makefile-colors
build(project): add fallback for color handling when tput is unavailable
2 parents 599e946 + 08542bf commit 3458afe

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ TOOL_TPARSE_VERSION := v0.16.0
2626
TOOL_TPARSE_PKG := github.com/mfridman/$(TOOL_TPARSE_NAME)@$(TOOL_TPARSE_VERSION)
2727
TOOL_TPARSE_BIN := ${TOOLS_FOLDER}/$(TOOL_TPARSE_NAME)/$(TOOL_TPARSE_VERSION)/$(TOOL_TPARSE_NAME)
2828

29-
# Some colors
30-
COLOR_GREEN = $(shell tput -Txterm setaf 2)
31-
COLOR_YELLOW = $(shell tput -Txterm setaf 3)
32-
COLOR_WHITE = $(shell tput -Txterm setaf 7)
33-
COLOR_CYAN = $(shell tput -Txterm setaf 6)
34-
COLOR_RED = $(shell tput -Txterm setaf 1)
35-
COLOR_RESET = $(shell tput -Txterm sgr0)
29+
# Some colors (if supported)
30+
define get_color
31+
$(shell tput -Txterm $(1) $(2) 2>/dev/null || echo "")
32+
endef
33+
34+
COLOR_GREEN = $(call get_color,setaf,2)
35+
COLOR_YELLOW = $(call get_color,setaf,3)
36+
COLOR_WHITE = $(call get_color,setaf,7)
37+
COLOR_CYAN = $(call get_color,setaf,6)
38+
COLOR_RED = $(call get_color,setaf,1)
39+
COLOR_RESET = $(call get_color,sgr0,)
3640

3741
# Blockchain constants
3842
CHAIN := localnet

0 commit comments

Comments
 (0)