Skip to content

Commit

Permalink
fix: clarify the wording when no version is set (#1088)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Rose <offline@offby1.net>
Co-authored-by: jthegedus <jthegedus@hey.com>
  • Loading branch information
3 people committed Nov 14, 2021
1 parent ca77d42 commit 4116284
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 79 deletions.
2 changes: 1 addition & 1 deletion lib/commands/command-current.bash
Expand Up @@ -31,7 +31,7 @@ plugin_current_command() {
printf "$terminal_format" "$plugin" "$version" "$description" 1>&2
return 1
elif [ -z "$full_version" ]; then
description="No version set. Run \"asdf <global|shell|local> $plugin <version>\""
description="No version is set. Run \"asdf <global|shell|local> $plugin <version>\""
printf "$terminal_format" "$plugin" "______" "$description" 1>&2
return 126
else
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.bash
Expand Up @@ -223,7 +223,7 @@ find_versions() {

display_no_version_set() {
local plugin_name=$1
printf "No version set for %s; please run \`asdf <global | shell | local> %s <version>\`\\n" "$plugin_name" "$plugin_name"
printf "No version is set for %s; please run \`asdf <global | shell | local> %s <version>\`\\n" "$plugin_name" "$plugin_name"
}

get_version_from_env() {
Expand Down Expand Up @@ -798,7 +798,7 @@ with_shim_executable() {
done
printf "\\n%s %s\\n" "or add one of the following versions in your config file at" "$closest_tool_version"
else
printf "%s %s\\n" "No version 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"
fi
shim_plugin_versions "${shim_name}"
Expand Down
27 changes: 13 additions & 14 deletions test/current_command.bats
Expand Up @@ -19,7 +19,7 @@ teardown() {

@test "current should derive from the current .tool-versions" {
cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
expected="dummy 1.1.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand All @@ -29,7 +29,7 @@ teardown() {

@test "current should handle long version name" {
cd $PROJECT_DIR
echo "dummy nightly-2000-01-01" >> $PROJECT_DIR/.tool-versions
echo "dummy nightly-2000-01-01" >>$PROJECT_DIR/.tool-versions
expected="dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand All @@ -39,19 +39,18 @@ teardown() {

@test "current should handle multiple versions" {
cd $PROJECT_DIR
echo "dummy 1.2.0 1.1.0" >> $PROJECT_DIR/.tool-versions
echo "dummy 1.2.0 1.1.0" >>$PROJECT_DIR/.tool-versions
expected="dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
[ "$status" -eq 0 ]
[ "$output" = "$expected" ]
}


@test "current should derive from the legacy file if enabled" {
cd $PROJECT_DIR
echo 'legacy_version_file = yes' > $HOME/.asdfrc
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
echo 'legacy_version_file = yes' >$HOME/.asdfrc
echo '1.2.0' >>$PROJECT_DIR/.dummy-version
expected="dummy 1.2.0 $PROJECT_DIR/.dummy-version"

run asdf current "dummy"
Expand All @@ -70,7 +69,7 @@ teardown() {

@test "current should error when no version is set" {
cd $PROJECT_DIR
expected="dummy ______ No version set. Run \"asdf <global|shell|local> dummy <version>\""
expected="dummy ______ No version is set. Run \"asdf <global|shell|local> dummy <version>\""

run asdf current "dummy"
[ "$status" -eq 126 ]
Expand All @@ -79,7 +78,7 @@ teardown() {

@test "current should error when a version is set that isn't installed" {
cd $PROJECT_DIR
echo 'dummy 9.9.9' >> $PROJECT_DIR/.tool-versions
echo 'dummy 9.9.9' >>$PROJECT_DIR/.tool-versions
expected="dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""

run asdf current "dummy"
Expand All @@ -98,11 +97,11 @@ teardown() {
install_mock_plugin "baz"

cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >>$PROJECT_DIR/.tool-versions

run asdf current
expected="baz ______ No version set. Run \"asdf <global|shell|local> baz <version>\"
expected="baz ______ No version is set. Run \"asdf <global|shell|local> baz <version>\"
dummy 1.1.0 $PROJECT_DIR/.tool-versions
foobar 1.0.0 $PROJECT_DIR/.tool-versions"

Expand All @@ -117,8 +116,8 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"
install_mock_plugin_version "y" "2.1.0"

cd $PROJECT_DIR
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
echo 'y 2.1.0' >> $PROJECT_DIR/.tool-versions
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'y 2.1.0' >>$PROJECT_DIR/.tool-versions

run asdf current "y"
[ "$status" -eq 0 ]
Expand All @@ -136,7 +135,7 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"

@test "current should handle comments" {
cd $PROJECT_DIR
echo "dummy 1.2.0 # this is a comment" >> $PROJECT_DIR/.tool-versions
echo "dummy 1.2.0 # this is a comment" >>$PROJECT_DIR/.tool-versions
expected="dummy 1.2.0 $PROJECT_DIR/.tool-versions"

run asdf current "dummy"
Expand Down

0 comments on commit 4116284

Please sign in to comment.