mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-19 05:58:43 -04:00
New feature: Attempt installing a local development version that already exists.
This commit is contained in:
@@ -22,7 +22,7 @@ function __gvmtool_install {
|
||||
__gvmtool_check_candidate_present "${CANDIDATE}" || return 1
|
||||
__gvmtool_determine_version "$2" "$3" || return 1
|
||||
|
||||
if [ -d "${GVM_DIR}/${CANDIDATE}/${VERSION}" ]; then
|
||||
if [[ -d "${GVM_DIR}/${CANDIDATE}/${VERSION}" || -h "${GVM_DIR}/${CANDIDATE}/${VERSION}" ]]; then
|
||||
echo ""
|
||||
echo "Stop! ${CANDIDATE} ${VERSION} is already installed."
|
||||
return 1
|
||||
|
||||
@@ -11,6 +11,11 @@ Feature: Local Development Versions
|
||||
And the candidate "groovy" version "2.1-SNAPSHOT" is linked to "/tmp/groovy-core"
|
||||
|
||||
Scenario: Attempt installing a local development version that already exists
|
||||
Given the candidate "groovy" version "2.1-SNAPSHOT" does not exist
|
||||
And the candidate "groovy" version "2.1-SNAPSHOT" is already linked to "/tmp/groovy-core"
|
||||
When I enter "gvm install groovy 2.1-SNAPSHOT /tmp/groovy-core"
|
||||
Then I see "Stop! groovy 2.1-SNAPSHOT is already installed."
|
||||
And the candidate "groovy" version "2.1-SNAPSHOT" is linked to "/tmp/groovy-core"
|
||||
|
||||
Scenario: Uninstall a local development version
|
||||
|
||||
|
||||
@@ -55,7 +55,21 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is linked to "([^"]*)"$') { Str
|
||||
def versionFolder = fileSystem.getPath(versionLocation)
|
||||
|
||||
assert Files.isSymbolicLink(versionFolder)
|
||||
assert Files.readSymbolicLink(versionFolder).toString() == directory
|
||||
|
||||
def link = Files.readSymbolicLink(versionFolder).toString()
|
||||
assert link == directory
|
||||
}
|
||||
|
||||
And(~'^the candidate "([^"]*)" version "([^"]*)" is already linked to "([^"]*)"$') { String candidate, String version, String folder ->
|
||||
def fileSystem = FileSystems.default
|
||||
|
||||
def candidateFolder = "$gvmDir/$candidate" as File
|
||||
candidateFolder.mkdirs()
|
||||
|
||||
def link = fileSystem.getPath("$gvmDir/$candidate/$version")
|
||||
def target = prepareLocalCandidateFolder(folder, candidate, version)
|
||||
|
||||
Files.createSymbolicLink(link, target)
|
||||
}
|
||||
|
||||
private prepareCandidateFolder(String baseDir, String candidate, String version) {
|
||||
@@ -69,13 +83,12 @@ private prepareLocalCandidateFolder(String baseDir, String candidate, String ver
|
||||
|
||||
private prepareCandidateBinFolder(String folder, String candidate, String version) {
|
||||
def fileSystem = FileSystems.default
|
||||
def folderPath = fileSystem.getPath("$folder")
|
||||
|
||||
def binFolder = fileSystem.getPath("$folder/bin")
|
||||
Files.createDirectories binFolder
|
||||
prepareCandidateExecutable binFolder, candidate, version
|
||||
def binFolderPath = fileSystem.getPath("$folder/bin")
|
||||
Files.createDirectories binFolderPath
|
||||
prepareCandidateExecutable binFolderPath, candidate, version
|
||||
|
||||
folderPath
|
||||
return fileSystem.getPath("$folder")
|
||||
}
|
||||
|
||||
private prepareCandidateExecutable(Path binFolder, String candidate, String version) {
|
||||
|
||||
Reference in New Issue
Block a user