Retrieve asdf_data_dir from environment variable

This commit is contained in:
Jose Luis Salas 2018-09-16 18:39:21 +02:00
parent c86707c55f
commit d1782f456e
No known key found for this signature in database
GPG Key ID: 2C938A963B1DBC31
3 changed files with 9 additions and 12 deletions

View File

@ -17,7 +17,7 @@ ASDF_DIR="$(dirname "$current_script_path")"
# replace all occurrences - ${parameter//pattern/string}
ASDF_BIN="${ASDF_DIR}/bin"
ASDF_SHIMS="${ASDF_DIR}/shims"
ASDF_USER_SHIMS="${HOME}/.asdf/shims"
ASDF_USER_SHIMS="${ASDF_DATA_DIR:-$HOME/.asdf}"
[[ ":$PATH:" == *":${ASDF_BIN}:"* ]] && PATH="${PATH//$ASDF_BIN:/}"
[[ ":$PATH:" == *":${ASDF_SHIMS}:"* ]] && PATH="${PATH//$ASDF_SHIMS:/}"
[[ ":$PATH:" == *":${ASDF_USER_SHIMS}:"* ]] && PATH="${PATH//$ASDF_USER_SHIMS:/}"

View File

@ -33,10 +33,10 @@ get_install_type(){
asdf_data_dir(){
local data_dir
if [ "$(get_install_type)" = "user" ]; then
data_dir="${HOME}/.asdf"
if ! [ -z "${ASDF_DATA_DIR}" ]; then
data_dir="${ASDF_DATA_DIR}"
else
data_dir="$(asdf_dir)"
data_dir="$HOME/.asdf"
fi
echo "$data_dir"
@ -65,16 +65,13 @@ list_installed_versions() {
local plugin_path
plugin_path=$(get_plugin_path "$plugin_name")
local install_dir
install_dir="$(asdf_data_dir)/installs"
local plugin_installs_path
plugin_installs_path=${install_dir}/${plugin_name}
plugin_installs_path="$(asdf_data_dir)/installs/${plugin_name}"
if [ -d "$plugin_installs_path" ]; then
# shellcheck disable=SC2045
# shellcheck disable=SC2045
for install in $(ls -d "${plugin_installs_path}"/*/ 2>/dev/null); do
basename "$install" | sed 's/^ref-/ref:/'
basename "$install" | sed 's/^ref-/ref:/'
done
fi
}

View File

@ -125,11 +125,11 @@ teardown() {
}
@test "asdf_data_dir should return user dir if configured" {
echo "install_type = user" > $HOME/.asdfrc
ASDF_DATA_DIR="/tmp/wadus"
run asdf_data_dir
[ "$status" -eq 0 ]
[ "$output" = "$HOME/.asdf" ]
[ "$output" = "$ASDF_DATA_DIR" ]
}
@test "find_version should return \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {