Skip to content

Commit

Permalink
fix: always use ASDF_DEFAULT_TOOL_VERSIONS_FILENAME for filename when…
Browse files Browse the repository at this point in the history
… present

Fixes #1082
  • Loading branch information
Stratus3D committed May 25, 2022
1 parent 788ccab commit 43bcb82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/functions/versions.bash
Expand Up @@ -14,13 +14,17 @@ version_command() {
shift 2
local versions=("$@")

local file_name
local file

file_name="$(version_file_name)"

if [ "$cmd" = "global" ]; then
file=${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME:-$HOME/.tool-versions}
file="$HOME/$file_name"
elif [ "$cmd" = "local-tree" ]; then
file=$(find_tool_versions)
else # cmd = local
file="$(pwd)/.tool-versions"
file="$(pwd)/$file_name"
fi

if [ -L "$file" ]; then
Expand Down
12 changes: 9 additions & 3 deletions lib/utils.bash
Expand Up @@ -156,10 +156,12 @@ get_version_in_dir() {
local legacy_filenames=$3

local asdf_version
asdf_version=$(parse_asdf_version_file "$search_path/.tool-versions" "$plugin_name")

file_name=$(version_file_name)
asdf_version=$(parse_asdf_version_file "$search_path/$file_name" "$plugin_name")

if [ -n "$asdf_version" ]; then
printf "%s\\n" "$asdf_version|$search_path/.tool-versions"
printf "%s\\n" "$asdf_version|$search_path/$file_name"
return 0
fi

Expand All @@ -174,6 +176,10 @@ get_version_in_dir() {
done
}

version_file_name() {
printf "%s" "${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME:-.tool-versions}"
}

find_versions() {
local plugin_name=$1
local search_path=$2
Expand Down Expand Up @@ -431,7 +437,7 @@ get_plugin_source_url() {
}

find_tool_versions() {
find_file_upwards ".tool-versions"
find_file_upwards "$(version_file_name)"
}

find_file_upwards() {
Expand Down

0 comments on commit 43bcb82

Please sign in to comment.