From ea181645b0040f854112706ae09d76e47333f02f Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 16 Aug 2023 18:33:19 +0200 Subject: [PATCH] setup.sh: Extract environment recration to function --- setup.sh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index 5f116c0e9..dd2588548 100755 --- a/setup.sh +++ b/setup.sh @@ -199,6 +199,23 @@ function check_git_changes() { fi } +function recreate_environments() { + if [ -d ".env" ]; then + # Remove old virtual env + echo "- Deleting your previous virtual env" + echo "Warning: Your new environment will be at .venv!" + rm -rf .env + fi + + echo + ${PYTHON} -m venv .venv + if [ $? -ne 0 ]; then + echo "Could not create virtual environment. Leaving now" + exit 1 + fi + +} + # Reset Develop or Stable branch function reset() { echo_block "Resetting branch and virtual env" @@ -225,17 +242,8 @@ function reset() { else echo "Reset ignored because you are not on 'stable' or 'develop'." fi + recreate_environments - if [ -d ".env" ]; then - echo "- Deleting your previous virtual env" - rm -rf .env - fi - echo - ${PYTHON} -m venv .env - if [ $? -ne 0 ]; then - echo "Could not create virtual environment. Leaving now" - exit 1 - fi updateenv }