mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Provide dedicated message for obsolete shim case
When a shimmed command can't find usable plugin version, we used to do several detection then output suggestion to user. The original message assumes "preset" plugin version is not installed, which could be false when shimmed command has old `asdf-plugin:` version written, while not being updated when install newer plugin version. Here add small `preset_plugin_installed` flag to detect if any considered "missing" plugin is in fact exist. Print only simple message for it. Example output: Shimmed command 'yarn' has no matched plugin version Check the executable or try install yarn for your preset plugin version
This commit is contained in:
parent
e00e4ac560
commit
897ea7f014
@ -803,6 +803,7 @@ with_shim_executable() {
|
|||||||
(
|
(
|
||||||
local preset_plugin_versions
|
local preset_plugin_versions
|
||||||
preset_plugin_versions=()
|
preset_plugin_versions=()
|
||||||
|
local preset_plugin_installed=
|
||||||
local closest_tool_version
|
local closest_tool_version
|
||||||
closest_tool_version=$(find_tool_versions)
|
closest_tool_version=$(find_tool_versions)
|
||||||
|
|
||||||
@ -815,10 +816,18 @@ with_shim_executable() {
|
|||||||
IFS=' ' read -r -a shim_versions <<<"$version_string"
|
IFS=' ' read -r -a shim_versions <<<"$version_string"
|
||||||
local usable_plugin_versions
|
local usable_plugin_versions
|
||||||
for shim_version in "${shim_versions[@]}"; do
|
for shim_version in "${shim_versions[@]}"; do
|
||||||
|
if grep -q "$shim_version" <<<"$(asdf list "$shim_plugin")"; then
|
||||||
|
preset_plugin_installed="yes"
|
||||||
|
else
|
||||||
preset_plugin_versions+=("$shim_plugin $shim_version")
|
preset_plugin_versions+=("$shim_plugin $shim_version")
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ -n "$preset_plugin_installed" ]; then
|
||||||
|
printf "%s '%s' %s\n" "Shimmed command" "$shim_name" "has no matched plugin version"
|
||||||
|
printf "%s %s %s\n" "Check the executable or try install" "$shim_name" "for your preset plugin version"
|
||||||
|
else
|
||||||
if [ -n "${preset_plugin_versions[*]}" ]; then
|
if [ -n "${preset_plugin_versions[*]}" ]; then
|
||||||
printf "%s %s\n" "No preset version installed for command" "$shim_name"
|
printf "%s %s\n" "No preset version installed for command" "$shim_name"
|
||||||
printf "%s\n\n" "Please install a version by running one of the following:"
|
printf "%s\n\n" "Please install a version by running one of the following:"
|
||||||
@ -826,11 +835,13 @@ with_shim_executable() {
|
|||||||
printf "%s %s\n" "asdf install" "$preset_plugin_version"
|
printf "%s %s\n" "asdf install" "$preset_plugin_version"
|
||||||
done
|
done
|
||||||
printf "\n%s %s\n" "or add one of the following versions in your config file at" "$closest_tool_version"
|
printf "\n%s %s\n" "or add one of the following versions in your config file at" "$closest_tool_version"
|
||||||
|
shim_plugin_versions "${shim_name}"
|
||||||
else
|
else
|
||||||
printf "%s %s\n" "No version is set for command" "$shim_name"
|
printf "%s %s\n" "No version is set for command" "$shim_name"
|
||||||
printf "%s %s\n" "Consider adding one of the following versions in your config file at" "$closest_tool_version"
|
printf "%s %s\n" "Consider adding one of the following versions in your config file at" "$closest_tool_version"
|
||||||
fi
|
|
||||||
shim_plugin_versions "${shim_name}"
|
shim_plugin_versions "${shim_name}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
) >&2
|
) >&2
|
||||||
|
|
||||||
return 126
|
return 126
|
||||||
|
@ -129,7 +129,7 @@ teardown() {
|
|||||||
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
|
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "issue #928" {
|
@test "shim exec should suggest to check obsolete shim" {
|
||||||
# Install 1.0, with fake "dummyman" command, shimmed for 1.0
|
# Install 1.0, with fake "dummyman" command, shimmed for 1.0
|
||||||
run asdf install dummy 1.0
|
run asdf install dummy 1.0
|
||||||
echo "echo Dummy Manager" >"$ASDF_DIR/installs/dummy/1.0/bin/dummyman"
|
echo "echo Dummy Manager" >"$ASDF_DIR/installs/dummy/1.0/bin/dummyman"
|
||||||
@ -138,7 +138,6 @@ teardown() {
|
|||||||
|
|
||||||
# Install 1.3
|
# Install 1.3
|
||||||
run asdf install dummy 1.3
|
run asdf install dummy 1.3
|
||||||
|
|
||||||
echo "dummy 1.3" >"$PROJECT_DIR/.tool-versions"
|
echo "dummy 1.3" >"$PROJECT_DIR/.tool-versions"
|
||||||
|
|
||||||
# reshim doesn't help
|
# reshim doesn't help
|
||||||
@ -146,17 +145,11 @@ teardown() {
|
|||||||
run asdf shim-versions dummyman
|
run asdf shim-versions dummyman
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[ "$output" = "dummy 1.0" ]
|
[ "$output" = "dummy 1.0" ]
|
||||||
|
|
||||||
run "$ASDF_DIR/shims/dummyman"
|
run "$ASDF_DIR/shims/dummyman"
|
||||||
[ "$status" -eq 126 ]
|
[ "$status" -eq 126 ]
|
||||||
echo ">> $output" >&3
|
|
||||||
|
|
||||||
# Below is current (misleading) message
|
echo "$output" | grep -q "Shimmed command 'dummyman' has no matched plugin version" 2>/dev/null
|
||||||
echo "$output" | grep -q "No preset version installed for command dummyman" 2>/dev/null
|
echo "$output" | grep -q "Check the executable or try install dummyman for your preset plugin version" 2>/dev/null
|
||||||
echo "$output" | grep -q "Please install a version by running one of the following:" 2>/dev/null
|
|
||||||
echo "$output" | grep -q "asdf install dummy 1.3" 2>/dev/null
|
|
||||||
echo "$output" | grep -q "or add one of the following versions in your config file at $PROJECT_DIR/.tool-versions" 2>/dev/null
|
|
||||||
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "shim exec should execute first plugin that is installed and set" {
|
@test "shim exec should execute first plugin that is installed and set" {
|
||||||
|
Loading…
Reference in New Issue
Block a user