Skip to content

Commit e557c9a

Browse files
felipecrsmarc0der
authored andcommitted
Add selfupdate_enable config and respect auto_answer when auto updating
This also deprecates the auto_selfupdate config.
1 parent cc1358b commit e557c9a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/main/bash/sdkman-main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function sdk() {
153153
fi
154154

155155
# Attempt upgrade after all is done
156-
if [[ "$COMMAND" != "selfupdate" ]]; then
156+
if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_enable" == true ]]; then
157157
__sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION"
158158
fi
159159
return $final_rc

src/main/bash/sdkman-selfupdate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function __sdkman_auto_update() {
4848
__sdkman_echo_no_colour "The current version is $remote_version, but you have $version."
4949
echo ""
5050

51-
if [[ "$sdkman_auto_selfupdate" != "true" ]]; then
51+
if [[ "$sdkman_auto_answer" == false ]]; then
5252
__sdkman_echo_confirm "Would you like to upgrade now? (Y/n): "
5353
read upgrade
5454
fi

src/test/resources/features/self_update.feature

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Feature: Self Update
4444

4545
Scenario: Automatically Selfupdate
4646
Given an outdated initialised environment
47-
And the configuration file has been primed with "sdkman_auto_selfupdate=true"
47+
And the configuration file has been primed with "sdkman_auto_answer=true"
4848
And the system is bootstrapped
4949
When I enter "sdk help"
5050
Then I see "A new version of SDKMAN is available..."
@@ -54,14 +54,22 @@ Feature: Self Update
5454

5555
Scenario: Do not automatically Selfupdate
5656
Given an outdated initialised environment
57-
And the configuration file has been primed with "sdkman_auto_selfupdate=false"
57+
And the configuration file has been primed with "sdkman_auto_answer=false"
5858
And the system is bootstrapped
5959
When I enter "sdk help" and answer "n"
6060
Then I see "A new version of SDKMAN is available..."
6161
And I see "Would you like to upgrade now? (Y/n)"
6262
And I see "Not upgrading today..."
6363
And I do not see "Successfully upgraded SDKMAN."
6464

65+
Scenario: Do not check and prompt for update
66+
Given an outdated initialised environment
67+
And the configuration file has been primed with "sdkman_selfupdate_enable=false"
68+
And the system is bootstrapped
69+
When I enter "sdk help"
70+
Then I do not see "A new version of SDKMAN is available..."
71+
And I do not see "Would you like to upgrade now? (Y/n)"
72+
6573
Scenario: Bother the user with Upgrade message once a day
6674
Given an outdated initialised environment
6775
And the system is bootstrapped

0 commit comments

Comments
 (0)