2017-03-14 06:56:59 -07:00
|
|
|
current_version() {
|
|
|
|
local plugin_name=$1
|
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
check_if_plugin_exists "$plugin_name"
|
2017-03-14 06:56:59 -07:00
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
local search_path
|
|
|
|
search_path=$(pwd)
|
|
|
|
local version_and_path
|
|
|
|
version_and_path=$(find_version "$plugin_name" "$search_path")
|
|
|
|
local version
|
|
|
|
version=$(cut -d '|' -f 1 <<< "$version_and_path");
|
2017-03-14 06:56:59 -07:00
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
check_if_version_exists "$plugin_name" "$version"
|
|
|
|
check_for_deprecated_plugin "$plugin_name"
|
2017-03-14 06:56:59 -07:00
|
|
|
|
|
|
|
if [ -z "$version" ]; then
|
2018-02-25 15:42:33 -07:00
|
|
|
display_no_version_set "$plugin_name"
|
2017-03-14 06:56:59 -07:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "$version"
|
2017-03-15 20:57:07 -07:00
|
|
|
exit 0
|
2017-03-14 06:56:59 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
which_command() {
|
|
|
|
local plugin_name=$1
|
2017-09-04 10:04:56 -07:00
|
|
|
local plugin_path
|
|
|
|
plugin_path=$(get_plugin_path "$plugin_name")
|
|
|
|
check_if_plugin_exists "$plugin_name"
|
2017-03-14 07:04:30 -07:00
|
|
|
local install_type="version"
|
2017-03-14 06:56:59 -07:00
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
local install_path
|
|
|
|
install_path=$(get_install_path "$plugin_name" "$install_type" "$(current_version "$plugin_name")")
|
2017-03-14 06:56:59 -07:00
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
if [ -d "$install_path" ]; then
|
|
|
|
echo "$install_path/bin/$plugin_name"
|
2017-03-14 06:56:59 -07:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Version not installed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2017-03-15 20:57:07 -07:00
|
|
|
|
|
|
|
# Warn if the plugin isn't using the updated legacy file api.
|
|
|
|
check_for_deprecated_plugin() {
|
|
|
|
local plugin_name=$1
|
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
local plugin_path
|
|
|
|
plugin_path=$(get_plugin_path "$plugin_name")
|
|
|
|
local legacy_config
|
|
|
|
legacy_config=$(get_asdf_config_value "legacy_version_file")
|
2017-03-15 20:57:07 -07:00
|
|
|
local deprecated_script="${plugin_path}/bin/get-version-from-legacy-file"
|
|
|
|
local new_script="${plugin_path}/bin/list-legacy-filenames"
|
|
|
|
|
2017-09-04 10:04:56 -07:00
|
|
|
if [ "$legacy_config" = "yes" ] && [ -f "$deprecated_script" ] && [ ! -f "$new_script" ]; then
|
2017-03-15 20:57:07 -07:00
|
|
|
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
|
|
|
|
}
|