Merge pull request #315 from mxie/mx-include-plugin-name-in-error-output

Include plugin name in error message if plugin doesn't exist
This commit is contained in:
Daniel Perez 2018-05-01 10:59:04 +09:00 committed by GitHub
commit b3408a0eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 7 deletions

View File

@ -54,14 +54,16 @@ list_installed_versions() {
}
check_if_plugin_exists() {
local plugin_name=$1
# Check if we have a non-empty argument
if [ -z "${1}" ]; then
display_error "No plugin given"
exit 1
fi
if [ ! -d "$(asdf_dir)/plugins/$1" ]; then
display_error "No such plugin"
if [ ! -d "$(asdf_dir)/plugins/$plugin_name" ]; then
display_error "No such plugin: $plugin_name"
exit 1
fi
}

View File

@ -41,7 +41,7 @@ teardown() {
@test "current should error when the plugin doesn't exist" {
run current_command "foobar"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin" ]
[ "$output" = "No such plugin: foobar" ]
}
@test "current should error when no version is set" {

View File

@ -31,7 +31,7 @@ teardown() {
@test "plugin_remove_command should exit with 1 when passed invalid plugin name" {
run plugin_remove_command "does-not-exist"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin" ]
[ "$output" = "No such plugin: does-not-exist" ]
}
@test "plugin_remove_command should remove installed versions" {

View File

@ -19,7 +19,7 @@ teardown() {
@test "check_if_version_exists should exit with 1 if plugin does not exist" {
run check_if_version_exists "inexistent" "1.0.0"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin" ]
[ "$output" = "No such plugin: inexistent" ]
}
@test "check_if_version_exists should exit with 1 if version does not exist" {

View File

@ -30,7 +30,7 @@ teardown() {
@test "local should emit an error when plugin does not exist" {
run local_command "inexistent" "1.0.0"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin" ]
[ "$output" = "No such plugin: inexistent" ]
}
@test "local should emit an error when plugin version does not exist" {

View File

@ -43,5 +43,5 @@ teardown() {
@test "which should error when the plugin doesn't exist" {
run which_command "foobar"
[ "$status" -eq 1 ]
[ "$output" = "No such plugin" ]
[ "$output" = "No such plugin: foobar" ]
}