2023-07-27 19:48:40 +03:00
|
|
|
#!/usr/bin/env bash
|
2023-10-22 13:36:36 +03:00
|
|
|
# scripts/set-env-test.sh
|
2023-07-27 19:48:40 +03:00
|
|
|
|
|
|
|
# Get script's directory
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
|
|
|
# Construct the absolute path of .env file in the project root directory
|
|
|
|
ENV_PATH="${SCRIPT_DIR}/../.env.test"
|
|
|
|
|
|
|
|
# Check if the file exists
|
|
|
|
if [ -f "${ENV_PATH}" ]; then
|
|
|
|
echo "🔵 - Loading environment variables from "${ENV_PATH}"..."
|
|
|
|
# Export env vars
|
2023-08-01 00:36:04 +03:00
|
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
|
|
if echo "$line" | grep -F = &>/dev/null
|
|
|
|
then
|
|
|
|
varname=$(echo "$line" | cut -d '=' -f 1)
|
|
|
|
varvalue=$(echo "$line" | cut -d '=' -f 2- | cut -d '#' -f 1)
|
|
|
|
export "$varname"="$varvalue"
|
|
|
|
fi
|
|
|
|
done < <(grep -v '^#' "${ENV_PATH}")
|
2023-07-27 19:48:40 +03:00
|
|
|
else
|
|
|
|
echo "Error: ${ENV_PATH} does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|