Skip to content

Commit b3a830d

Browse files
committed
chore: update merge-branches.sh
1 parent 797c67e commit b3a830d

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎api/scripts/merge-branches.sh‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,29 @@
1818

1919
set -euo pipefail
2020

21+
# Colors only when writing to a terminal, and not when NO_COLOR is set.
22+
green="" reset="" red_err="" reset_err=""
23+
if [[ -z "${NO_COLOR:-}" ]]; then
24+
if [[ -t 1 ]]; then
25+
green=$'\033[32m'
26+
reset=$'\033[0m'
27+
fi
28+
if [[ -t 2 ]]; then
29+
red_err=$'\033[31m'
30+
reset_err=$'\033[0m'
31+
fi
32+
fi
33+
2134
log() {
2235
echo "==> $*"
2336
}
2437

38+
success() {
39+
echo "${green}==> $*${reset}"
40+
}
41+
2542
error() {
26-
echo "==> ERROR: $*" >&2
43+
echo "${red_err}==> ERROR: $*${reset_err}" >&2
2744
}
2845

2946
fail() {
@@ -164,4 +181,4 @@ if [[ ${#failed_pushes[@]} -gt 0 ]]; then
164181
fail "Merged all branches, but failed to push: ${failed_pushes[*]}"
165182
fi
166183

167-
log "Done. Merged and pushed: ${branches[*]}"
184+
success "Done. Merged and pushed: ${branches[*]}"

0 commit comments

Comments
 (0)