-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #575 from klane/install-latest
Add support for installing the latest stable version of a tool
- Loading branch information
Showing
11 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
latest_command() { | ||
DEFAULT_QUERY="[0-9]" | ||
|
||
local plugin_name=$1 | ||
local query=$2 | ||
|
||
[[ -z $query ]] && query="$DEFAULT_QUERY" | ||
|
||
# pattern from xxenv-latest (https://github.com/momo-lab/xxenv-latest) | ||
load_cmd "list-all" | ||
list_all_command "$plugin_name" "$query" \ | ||
| grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\.]rc|-alpha|-beta|[-\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" \ | ||
| sed 's/^\s\+//' \ | ||
| sort --version-sort \ | ||
| tail -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bats | ||
|
||
load test_helpers | ||
|
||
setup() { | ||
setup_asdf_dir | ||
install_dummy_plugin | ||
} | ||
|
||
teardown() { | ||
clean_asdf_dir | ||
} | ||
|
||
@test "latest_command shows latest stable version" { | ||
run asdf latest dummy | ||
[ "$(echo -e "2.0")" == "$output" ] | ||
[ "$status" -eq 0 ] | ||
} | ||
|
||
@test "latest_command with version shows latest stable version that matches the given string" { | ||
run asdf latest dummy 1 | ||
[ "$(echo -e "1.1")" == "$output" ] | ||
[ "$status" -eq 0 ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters