diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 8e4075f7..27d7a183 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -90,9 +90,15 @@ function __sdkman_install_local_version { folder="$(pwd)/$folder" fi - __sdkman_echo_green "Linking ${candidate} ${version} to ${folder}" - ln -s "$folder" "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" - __sdkman_echo_green "Done installing!" + if [[ -d "$folder" ]]; then + __sdkman_echo_green "Linking ${candidate} ${version} to ${folder}" + ln -s "$folder" "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" + __sdkman_echo_green "Done installing!" + + else + __sdkman_echo_red "Invalid path! Refusing to link ${candidate} ${version} to ${folder}." + fi + echo "" } diff --git a/src/test/cucumber/local_developement_versions.feature b/src/test/cucumber/local_developement_versions.feature index 04ed9b12..d165a903 100644 --- a/src/test/cucumber/local_developement_versions.feature +++ b/src/test/cucumber/local_developement_versions.feature @@ -51,10 +51,17 @@ Feature: Local Development Versions Then I see "Using groovy version 2.1-SNAPSHOT in this shell" And the candidate "groovy" version "2.1-SNAPSHOT" should be in use - Scenario: Install a local development version from a relative path + Scenario: Install a local development version from a valid relative path Given the candidate "groovy" version "2.1-SNAPSHOT" is not available for download And I have a local candidate "groovy" version "2.1-SNAPSHOT" at relative path "some/relative/path/to/groovy" And the system is bootstrapped When I enter "sdk install groovy 2.1-SNAPSHOT some/relative/path/to/groovy" Then I see "Linking groovy 2.1-SNAPSHOT" And the candidate "groovy" version "2.1-SNAPSHOT" is linked to the relative path "some/relative/path/to/groovy" + + Scenario: Prevent installation of a local development version for an invalid path + Given the candidate "groovy" version "2.1-SNAPSHOT" is not available for download + And the system is bootstrapped + When I enter "sdk install groovy 2.1-SNAPSHOT /some/bogus/path/to/groovy" + Then I see "Invalid path! Refusing to link groovy 2.1-SNAPSHOT to /some/bogus/path/to/groovy." + And the candidate "groovy" version "2.1-SNAPSHOT" is not installed