Skip to content

Commit 1ae6d51

Browse files
committed
Refactor installation type detection and upgrade check logic
- Updated the installation_type function to use a case statement for improved readability and maintainability. - Modified the upgrade check to only apply for user installations, enhancing the script's behavior for different installation types.
1 parent e588733 commit 1ae6d51

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

bin/spin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ SPIN_ANSIBLE_COLLECTION_NAME="${SPIN_ANSIBLE_COLLECTION_NAME:-"serversideup.spin
4242
source "$SPIN_HOME/lib/functions.sh"
4343
setup_color
4444

45-
# Check for upgrades, except for development installs and on `spin update`
46-
if [[ "$(installation_type)" != "development" && "$1" != "update" ]]; then
45+
# Check for upgrades, for only user installs
46+
if [[ "$(installation_type)" == "user" && "$1" != "update" ]]; then
4747
check_for_upgrade
4848
fi
4949

lib/functions.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,17 @@ github_default_branch() {
639639
}
640640

641641
installation_type() {
642-
if [[ "$SPIN_HOME" =~ (/vendor/bin|/node_modules/.bin) ]]; then
643-
echo "project"
644-
elif [[ "$SPIN_HOME" =~ (\.spin) ]]; then
645-
echo "user"
646-
else
647-
echo "development"
648-
fi
642+
case "$SPIN_HOME" in
643+
*/vendor/*|*/node_modules/*)
644+
echo "project"
645+
;;
646+
*/.spin*)
647+
echo "user"
648+
;;
649+
*)
650+
echo "development"
651+
;;
652+
esac
649653
}
650654

651655
is_encrypted_with_ansible_vault() {

0 commit comments

Comments
 (0)