mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 17:48:18 -07:00
Merge branch 'vic-global_version_outside_home'
This commit is contained in:
commit
a3349dfc2c
35
lib/utils.sh
35
lib/utils.sh
@ -56,20 +56,11 @@ display_error() {
|
||||
echo >&2 $1
|
||||
}
|
||||
|
||||
find_version() {
|
||||
get_version_in_dir() {
|
||||
local plugin_name=$1
|
||||
local search_path=$2
|
||||
local legacy_filenames=$3
|
||||
|
||||
local plugin_path=$(get_plugin_path "$plugin_name")
|
||||
local legacy_config=$(get_asdf_config_value "legacy_version_file")
|
||||
local legacy_list_filenames_script="${plugin_path}/bin/list-legacy-filenames"
|
||||
local legacy_filenames=""
|
||||
|
||||
if [ "$legacy_config" = "yes" ] && [ -f $legacy_list_filenames_script ]; then
|
||||
legacy_filenames=$(bash "$legacy_list_filenames_script")
|
||||
fi
|
||||
|
||||
while [ "$search_path" != "/" ]; do
|
||||
local asdf_version=$(parse_asdf_version_file "$search_path/.tool-versions" $plugin_name)
|
||||
|
||||
if [ -n "$asdf_version" ]; then
|
||||
@ -85,9 +76,31 @@ find_version() {
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
find_version() {
|
||||
local plugin_name=$1
|
||||
local search_path=$2
|
||||
|
||||
local plugin_path=$(get_plugin_path "$plugin_name")
|
||||
local legacy_config=$(get_asdf_config_value "legacy_version_file")
|
||||
local legacy_list_filenames_script="${plugin_path}/bin/list-legacy-filenames"
|
||||
local legacy_filenames=""
|
||||
|
||||
if [ "$legacy_config" = "yes" ] && [ -f $legacy_list_filenames_script ]; then
|
||||
legacy_filenames=$(bash "$legacy_list_filenames_script")
|
||||
fi
|
||||
|
||||
while [ "$search_path" != "/" ]; do
|
||||
local version=$(get_version_in_dir "$plugin_name" "$search_path" "$legacy_filenames")
|
||||
if [ -n "$version" ]; then
|
||||
echo "$version"
|
||||
return 0
|
||||
fi
|
||||
search_path=$(dirname "$search_path")
|
||||
done
|
||||
|
||||
get_version_in_dir "$plugin_name" "$HOME" "$legacy_filenames"
|
||||
}
|
||||
|
||||
parse_asdf_version_file() {
|
||||
|
@ -92,3 +92,12 @@ teardown() {
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "0.2.0" ]
|
||||
}
|
||||
|
||||
@test "get_preset_version_for returns the global version from home when project is outside of home" {
|
||||
echo "dummy 0.1.0" > $HOME/.tool-versions
|
||||
PROJECT_DIR=$BASE_DIR/project
|
||||
mkdir -p $PROJECT_DIR
|
||||
run get_preset_version_for "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "0.1.0" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user