fix(config): resolve wrapper env from repo root and warn on deprecated .env
This commit is contained in:
@@ -16,11 +16,26 @@ set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Load local .env if it exists in current dir or workspace root
|
||||
if [[ -f .env ]]; then
|
||||
set -a; source .env; set +a
|
||||
elif [[ -f "$SCRIPT_DIR/../../.env" ]]; then
|
||||
set -a; source "$SCRIPT_DIR/../../.env"; set +a
|
||||
# Load local env file (.mam.env preferred, .env fallback) from workspace root or explicit MAM_ENV_FILE
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
TARGET_ENV="${MAM_ENV_FILE:-}"
|
||||
if [[ -z "$TARGET_ENV" ]]; then
|
||||
if [[ -f "$REPO_ROOT/.mam.env" ]]; then
|
||||
TARGET_ENV="$REPO_ROOT/.mam.env"
|
||||
elif [[ -f "$REPO_ROOT/.env" ]]; then
|
||||
TARGET_ENV="$REPO_ROOT/.env"
|
||||
echo "WARNING: Loading deprecated config file '$TARGET_ENV'. Please migrate to '.mam.env'." >&2
|
||||
elif [[ -f .mam.env ]]; then
|
||||
TARGET_ENV=".mam.env"
|
||||
echo "WARNING: Loading config from cwd relative path '$TARGET_ENV'." >&2
|
||||
elif [[ -f .env ]]; then
|
||||
TARGET_ENV=".env"
|
||||
echo "WARNING: Loading deprecated config from cwd relative path '$TARGET_ENV'. Please migrate to '.mam.env'." >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$TARGET_ENV" && -f "$TARGET_ENV" ]]; then
|
||||
set -a; source "$TARGET_ENV"; set +a
|
||||
fi
|
||||
|
||||
# Source EARLY (before any herdr usage in run_agent) — this is what turns
|
||||
|
||||
Reference in New Issue
Block a user