Validate path for local installation.

This commit is contained in:
Marco Vermeulen
2017-03-30 22:50:02 +01:00
parent 52cb511f99
commit 5caa2ec51f
2 changed files with 17 additions and 4 deletions

View File

@@ -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 ""
}

View File

@@ -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