From a17f7aede551b289a0ae1c8419d7912d96eadefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Tarot=20=28=40silopolis=29?= Date: Thu, 28 Dec 2023 12:54:51 +0100 Subject: [PATCH] scripts:bootstrap: only source `.env` file if it exists Also fix shellcheck warning when sourced files do not exist --- scripts/bootstrap.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 45dc49f..2097e7e 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -6,20 +6,26 @@ set -e #ux cwd="$(pwd)" ## Change to project directory cd "$(dirname "$0")/.." -# shellcheck source="../.env" -source .env +if [ -f .env ]; then + # shellcheck source="../.env" disable=SC1091 + source .env +fi ./scripts/python_setup.sh "$@" echo "-- Shell: Source profile in case it's been updated" -# shellcheck source="$HOME/.profile" +# shellcheck source="$HOME/.profile" disable=SC1091 source "$HOME/.profile" + echo "-- Activate Python virtual environment" # shellcheck source="../.venv/bin/activate" source .venv/bin/activate -echo "-- Source '.env' configuration file" -# shellcheck source="../.env" -source .env + +if [ -f .env ]; then + echo "-- Source '.env' configuration file" + # shellcheck source="../.env" disable=SC1091 + source .env +fi ## and go back cd "$cwd"