setup.sh: Extract environment recration to function

This commit is contained in:
Matthias 2023-08-16 18:33:19 +02:00
parent f607b8abfb
commit ea181645b0

View File

@ -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
}