mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Retrieve asdf_data_dir from environment variable
This commit is contained in:
parent
c86707c55f
commit
d1782f456e
2
asdf.sh
2
asdf.sh
@ -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:/}"
|
||||
|
15
lib/utils.sh
15
lib/utils.sh
@ -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
|
||||
}
|
||||
|
@ -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" {
|
||||
|
Loading…
Reference in New Issue
Block a user