Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(installer): graceful fallback to monochromic output when tput is unavailable #372

Merged
merged 3 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions installers/binstall/scripts/nix/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ download_binary_and_run_installer() {
need_cmd tar
need_cmd which
need_cmd dirname
need_cmd tput

# if $VERSION isn't provided or has 0 length, use version from Rover cargo.toml
# ${VERSION:-} checks if version exists, and if doesn't uses the default
Expand Down Expand Up @@ -143,14 +142,14 @@ get_architecture() {


say() {
local green=`tput setaf 2`
local reset=`tput sgr0`
local green=`tput setaf 2 2>/dev/null || echo ''`
local reset=`tput sgr0 2>/dev/null || echo ''`
echo "$1"
}

err() {
local red=`tput setaf 1`
local reset=`tput sgr0`
local red=`tput setaf 1 2>/dev/null || echo ''`
local reset=`tput sgr0 2>/dev/null || echo ''`
say "${red}ERROR${reset}: $1" >&2
exit 1
}
Expand Down Expand Up @@ -209,4 +208,4 @@ downloader() {
fi
}

download_binary_and_run_installer "$@" || exit 1
download_binary_and_run_installer "$@" || exit 1
12 changes: 5 additions & 7 deletions installers/binstall/scripts/nix/local-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ copy_binary_and_run_installer() {
need_cmd which
need_cmd dirname
need_cmd cargo
need_cmd tput

say "building rover"
ensure cargo build --workspace
Expand Down Expand Up @@ -101,16 +100,15 @@ get_architecture() {
RETVAL="$_arch"
}


say() {
local green=`tput setaf 2`
local reset=`tput sgr0`
local green=`tput setaf 2 2>/dev/null || echo ''`
local reset=`tput sgr0 2>/dev/null || echo ''`
echo " ${green}INFO${reset} sh::wrapper: $1"
}

err() {
local red=`tput setaf 1`
local reset=`tput sgr0`
local red=`tput setaf 1 2>/dev/null || echo ''`
local reset=`tput sgr0 2>/dev/null || echo ''`
say " ${red}ERROR${reset} sh::wrapper: $1" >&2
exit 1
}
Expand Down Expand Up @@ -149,4 +147,4 @@ ignore() {
"$@"
}

copy_binary_and_run_installer "$@" || exit 1
copy_binary_and_run_installer "$@" || exit 1