Skip to content

Commit

Permalink
move install type check and add latest-stable
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Schaller <ivan@schaller.sh>
  • Loading branch information
olofvndrhr committed Feb 22, 2023
1 parent e67f744 commit 6882e77
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
8 changes: 6 additions & 2 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ plugin_dir=$(dirname "$(dirname "${current_script_path}")")
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

# Download tar.gz file to the download directory
if [[ "${ASDF_INSTALL_TYPE}" != "version" ]]; then
fail "asdf-${TOOL_NAME} supports release installs only"
fi

# download tar.gz file to the download directory
download_release "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}"

# Extract contents of tar.gz file into the download directory
# extract contents of tar.gz file into the download directory
extract_release "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}"
2 changes: 2 additions & 0 deletions bin/help.overview
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugin_dir=$(dirname "$(dirname "${current_script_path}")")
source "${plugin_dir}/lib/utils.bash"

cat << EOF
> From the github page:
just is a handy way to save and run project-specific commands.
This readme is also available as a book.
Expand Down
6 changes: 5 additions & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ plugin_dir=$(dirname "$(dirname "${current_script_path}")")
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

install_version "${ASDF_INSTALL_TYPE}" "${ASDF_INSTALL_VERSION}" "${ASDF_INSTALL_PATH}" "${ASDF_DOWNLOAD_PATH}"
if [[ "${ASDF_INSTALL_TYPE}" != "version" ]]; then
fail "asdf-${TOOL_NAME} supports release installs only"
fi

install_version "${ASDF_INSTALL_VERSION}" "${ASDF_INSTALL_PATH}" "${ASDF_DOWNLOAD_PATH}"
11 changes: 11 additions & 0 deletions bin/latest-stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -euo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "${current_script_path}")")

# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

list_all_versions | sort_versions | tail -n 1
17 changes: 6 additions & 11 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,20 @@ function extract_release() {
if ! tar -xzf "${download_path}/${release_tar}" -C "${download_path}" just; then
fail "Could not extract ${release_tar}"
fi
rm "${download_path}/${release_tar}"
rm -f "${download_path}/${release_tar}"
}

function install_version() {
local install_type version install_path download_path tool_cmd
local version install_path download_path tool_cmd

install_type="${1}"
version="${2}"
install_path="${3%/bin}/bin"
download_path="${4}"

if [ "${install_type}" != "version" ]; then
fail "asdf-${TOOL_NAME} supports release installs only"
fi
version="${1}"
install_path="${2%/bin}/bin"
download_path="${3}"

if ! (
mkdir -p "${install_path}"

mv "${download_path}/just" "${install_path}"
mv -f "${download_path}/just" "${install_path}"

tool_cmd="$(echo "${TOOL_TEST}" | cut -d' ' -f1)"
if [[ ! -x "${install_path}/${tool_cmd}" ]]; then
Expand Down

0 comments on commit 6882e77

Please sign in to comment.