mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
First working version of utils.sh with legacy version file support.
This commit is contained in:
parent
30173d4dcf
commit
89c341829c
21
lib/utils.sh
21
lib/utils.sh
@ -74,6 +74,13 @@ get_preset_version_for() {
|
||||
local asdf_versions_path=$(get_asdf_versions_file_path)
|
||||
local matching_tool_version=""
|
||||
|
||||
# If .tool-versions is not in the working directory
|
||||
if [ "$asdf_versions_path" != "$(pwd)/.tool-versions" ]; then
|
||||
# Check for legacy version file
|
||||
matching_tool_version=$(get_tool_version_from_legacy_file $tool_name)
|
||||
fi
|
||||
|
||||
# No legacy file, see if we can use .tool-versions file
|
||||
if [ "$asdf_versions_path" != "" ]; then
|
||||
matching_tool_version=$(get_tool_version_from_file $asdf_versions_path $tool_name)
|
||||
fi
|
||||
@ -121,3 +128,17 @@ get_tool_version_from_file() {
|
||||
|
||||
echo $matching_tool_version
|
||||
}
|
||||
|
||||
get_tool_version_from_legacy_file() {
|
||||
local plugin_name=$1
|
||||
local legacy_tool_version=""
|
||||
local plugin_path=$(get_plugin_path $plugin_name)
|
||||
check_if_plugin_exists $plugin_path
|
||||
|
||||
if [ -f ${plugin_path}/bin/get_version_from_legacy_file ]; then
|
||||
local legacy_tool_version=$(bash ${plugin_path}/bin/get_version_from_legacy_file $(pwd))
|
||||
fi
|
||||
|
||||
# Should return the version/tag/commit/branch/path
|
||||
echo $legacy_tool_version
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user