mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-24 16:42:24 -04:00
Merge pull request #118 from dsyer/feature/autoinstall
Add gvm_auto_{install,use} in $GVM_DIR/etc/config
This commit is contained in:
@@ -31,8 +31,10 @@ function __gvmtool_install {
|
||||
if [[ ${VERSION_VALID} == 'valid' ]]; then
|
||||
__gvmtool_install_candidate_version "${CANDIDATE}" "${VERSION}" || return 1
|
||||
|
||||
echo -n "Do you want ${CANDIDATE} ${VERSION} to be set as default? (Y/n): "
|
||||
read USE
|
||||
if [[ -z "${gvm_auto_answer}" ]]; then
|
||||
echo -n "Do you want ${CANDIDATE} ${VERSION} to be set as default? (Y/n): "
|
||||
read USE
|
||||
fi
|
||||
if [[ -z "${USE}" || "${USE}" == "y" || "${USE}" == "Y" ]]; then
|
||||
echo ""
|
||||
echo "Setting ${CANDIDATE} ${VERSION} as default."
|
||||
|
||||
@@ -24,8 +24,10 @@ function __gvmtool_use {
|
||||
if [[ "${GVM_ONLINE}" == "true" && ! -d "${GVM_DIR}/${CANDIDATE}/${VERSION}" ]]; then
|
||||
echo ""
|
||||
echo "Stop! ${CANDIDATE} ${VERSION} is not installed."
|
||||
echo -n "Do you want to install it now? (Y/n): "
|
||||
read INSTALL
|
||||
if [[ -z "${gvm_auto_answer}" ]]; then
|
||||
echo -n "Do you want to install it now? (Y/n): "
|
||||
read INSTALL
|
||||
fi
|
||||
if [[ -z "${INSTALL}" || "${INSTALL}" == "y" || "${INSTALL}" == "Y" ]]; then
|
||||
__gvmtool_install_candidate_version "${CANDIDATE}" "${VERSION}"
|
||||
else
|
||||
|
||||
@@ -31,6 +31,14 @@ Feature: Install Candidate
|
||||
And I see "Setting grails 2.1.0 as default."
|
||||
Then the candidate "grails" version "2.1.0" should be the default
|
||||
|
||||
Scenario: Install a candidate and select to use it automatically
|
||||
And I have configured autoinstall="Y"
|
||||
When I enter "gvm install grails 2.1.0"
|
||||
Then the candidate "grails" version "2.1.0" is installed
|
||||
And I see "Done installing!"
|
||||
And I see "Setting grails 2.1.0 as default."
|
||||
Then the candidate "grails" version "2.1.0" should be the default
|
||||
|
||||
Scenario: Install a candidate and do not select to use it
|
||||
When I enter "gvm install grails 2.1.0" and answer "n"
|
||||
Then the candidate "grails" version "2.1.0" is installed
|
||||
|
||||
@@ -20,6 +20,13 @@ Feature: Use and Default Candidate
|
||||
Then I see "Using groovy version 1.8.8 in this shell."
|
||||
And the candidate "groovy" version "1.8.8" should be in use
|
||||
|
||||
Scenario: Use a candidate version that is automatically installed
|
||||
And I have configured autoinstall="Y"
|
||||
When I enter "gvm use groovy 1.8.8"
|
||||
Then I see "Stop! groovy 1.8.8 is not installed."
|
||||
Then I see "Using groovy version 1.8.8 in this shell."
|
||||
And the candidate "groovy" version "1.8.8" should be in use
|
||||
|
||||
Scenario: Use a candidate version that does not exist
|
||||
When I enter "gvm use groovy 1.9.9"
|
||||
Then I see "Stop! 1.9.9 is not a valid groovy version."
|
||||
|
||||
@@ -80,6 +80,11 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is already linked to "([^"]*)"$
|
||||
Files.createSymbolicLink(link, target)
|
||||
}
|
||||
|
||||
And(~'^I have configured autoinstall="([^"]*)"$') { String flag ->
|
||||
def configFile = new File("$gvmDir/etc/config")
|
||||
configFile.write "gvm_auto_answer=${flag}"
|
||||
}
|
||||
|
||||
private prepareCandidateFolder(String baseDir, String candidate, String version) {
|
||||
def directory = "$baseDir/$candidate/$version"
|
||||
prepareCandidateBinFolder directory, candidate, version
|
||||
|
||||
@@ -42,4 +42,4 @@ Then(~'^the candidate "([^"]*)" version "([^"]*)" should not be the default$') {
|
||||
Then(~'^the candidate "([^"]*)" is no longer selected$') { String candidate ->
|
||||
def symlink = new File("$gvmDir/$candidate/current")
|
||||
assert ! symlink.exists()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user