Skip to content

Commit

Permalink
add chmod and use --help instead of --version
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Schaller <ivan@schaller.sh>
  • Loading branch information
olofvndrhr committed Sep 1, 2023
1 parent 76431f9 commit 05272e8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/utils.bash
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

GH_REPO="https://github.com/casey/just"
TOOL_NAME="just"
TOOL_TEST="--version"
TOOL_TEST="--help"

function fail() {
echo -e "asdf-${TOOL_NAME}: ${*}"
Expand All @@ -14,8 +14,8 @@ function fail() {
# global vars
curl_opts=(-fsSL)

if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token ${GITHUB_API_TOKEN}")
if [[ -n "${GITHUB_API_TOKEN:-}" ]]; then
curl_opts+=(-H "Authorization: token ${GITHUB_API_TOKEN}")
fi

function sort_versions() {
Expand Down Expand Up @@ -102,12 +102,13 @@ function install_version() {
mkdir -p "${install_path}"

mv -f "${download_path}/${TOOL_NAME}" "${install_path}/${TOOL_NAME}"
chmod +x "${install_path}/${TOOL_NAME}"

if [[ ! -x "${install_path}/${TOOL_NAME}" ]]; then
rm -rf "${install_path}"
fail "Expected ${install_path}/${TOOL_NAME} to be executable"
fi
if ! "${install_path}/${TOOL_NAME}" "${TOOL_TEST}"; then
if ! "${install_path}/${TOOL_NAME}" "${TOOL_TEST}" > /dev/null; then
rm -rf "${install_path}"
fail "Error with command: '${TOOL_NAME} ${TOOL_TEST}'"
fi
Expand Down

0 comments on commit 05272e8

Please sign in to comment.