mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 09:38:16 -07:00
a1bc06fb82
Before this patch, with a `.tool-versions` file like: ``` lfe ref:master ``` `get_preset_version_for` would return `ref` instead of `ref:master`. Same was happening for `path:` versions. Actually there was PR #95 on which I based my changes but instead of using space as delimiter I went for using `|` which would be a lot more weird if present as part of a file path, this also allows to specify paths which have spaces which are much more frequent. Closes #94 #95
38 lines
1.2 KiB
Bash
38 lines
1.2 KiB
Bash
current_command() {
|
|
local plugin_name=$1
|
|
|
|
check_if_plugin_exists $plugin_name
|
|
|
|
local search_path=$(pwd)
|
|
local version_and_path=$(find_version "$plugin_name" "$search_path")
|
|
local version=$(cut -d '|' -f 1 <<< "$version_and_path");
|
|
local version_file_path=$(cut -d '|' -f 2 <<< "$version_and_path");
|
|
|
|
check_if_version_exists $plugin_name $version
|
|
check_for_deprecated_plugin $plugin_name
|
|
|
|
if [ -z "$version" ]; then
|
|
echo "No version set for $plugin_name"
|
|
exit 1
|
|
else
|
|
echo "$version (set by $version_file_path)"
|
|
fi
|
|
}
|
|
|
|
# Warn if the plugin isn't using the updated legacy file api.
|
|
check_for_deprecated_plugin() {
|
|
local plugin_name=$1
|
|
|
|
local plugin_path=$(get_plugin_path "$plugin_name")
|
|
local legacy_config=$(get_asdf_config_value "legacy_version_file")
|
|
local deprecated_script="${plugin_path}/bin/get-version-from-legacy-file"
|
|
local new_script="${plugin_path}/bin/list-legacy-filenames"
|
|
|
|
if [ "$legacy_config" = "yes" ] && [ -f $deprecated_script ] && [ ! -f $new_script ]; then
|
|
echo "Heads up! It looks like your $plugin_name plugin is out of date. You can update it with:"
|
|
echo ""
|
|
echo " asdf plugin-update $plugin_name"
|
|
echo ""
|
|
fi
|
|
}
|