mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-12-19 18:05:02 -07:00
Compare commits
5 Commits
a48e448526
...
90fccb06cb
Author | SHA1 | Date | |
---|---|---|---|
|
90fccb06cb | ||
|
36fd9f8a4b | ||
|
437453110c | ||
|
5c30032f44 | ||
|
5c69d8d852 |
@ -53,8 +53,12 @@ version_command() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if ! (check_if_version_exists "$plugin_name" "$version"); then
|
if ! (check_if_version_exists "$plugin_name" "$version"); then
|
||||||
version_not_installed_text "$plugin_name" "$version" 1>&2
|
closest_version=$(try_get_closest_version "$plugin_name" "$version")
|
||||||
exit 1
|
if [[ ! $closest_version ]]; then
|
||||||
|
version_not_installed_text "$plugin_name" "$version" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
version="$closest_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
resolved_versions+=("$version")
|
resolved_versions+=("$version")
|
||||||
|
@ -137,6 +137,26 @@ check_if_version_exists() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try_get_closest_version() {
|
||||||
|
local plugin_name=$1
|
||||||
|
local partial_version=$2
|
||||||
|
local versions
|
||||||
|
|
||||||
|
versions=$(list_installed_versions "$plugin_name")
|
||||||
|
|
||||||
|
if [ -n "${versions}" ]; then
|
||||||
|
for version in $versions; do
|
||||||
|
if [[ $version == $partial_version* ]]; then
|
||||||
|
matched_versions+=("$version")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${#matched_versions[@]} -eq 1 ]; then
|
||||||
|
printf "%s" "${matched_versions[0]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
version_not_installed_text() {
|
version_not_installed_text() {
|
||||||
local plugin_name=$1
|
local plugin_name=$1
|
||||||
local version=$2
|
local version=$2
|
||||||
|
@ -204,6 +204,18 @@ teardown() {
|
|||||||
[ "$(cat "$HOME/.tool-versions")" = "dummy 1.1.0" ]
|
[ "$(cat "$HOME/.tool-versions")" = "dummy 1.1.0" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "global should create a global .tool-versions file when a close version is found" {
|
||||||
|
run asdf global "dummy" "1.1"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(cat "$HOME/.tool-versions")" = "dummy 1.1.0" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "global should emit an error when a single close plugin version is not found" {
|
||||||
|
run asdf global "dummy" "1"
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[ "$output" = "version 1 is not installed for dummy" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "[global - dummy_plugin] with latest should use the latest installed version" {
|
@test "[global - dummy_plugin] with latest should use the latest installed version" {
|
||||||
run asdf global "dummy" "latest"
|
run asdf global "dummy" "latest"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
Loading…
Reference in New Issue
Block a user