Merge branch 'feat-active-config' into dev

This commit is contained in:
moux1024 2025-09-29 15:30:01 +08:00
commit e9cf23abb3
2 changed files with 0 additions and 72 deletions

View File

@ -14,42 +14,6 @@ echo "Build process started at $(date)" | tee $LOGFILE
# 获取当前分支名
current_branch=$(git rev-parse --abbrev-ref HEAD)
# 指定并加载环境变量文件dev 使用 .env.development
ENV_FILE=".env.development"
# 兼容 KEY=VALUE 与 KEY: VALUE 的 .env 行为,忽略注释与空行
load_env_file() {
local file="$1"
if [ -f "$file" ]; then
echo "Loading environment from $file" | tee -a $LOGFILE
while IFS= read -r raw || [ -n "$raw" ]; do
# 去除注释与首尾空白
local line="${raw%%#*}"
line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
[ -z "$line" ] && continue
# 将 KEY: VALUE 转换为 KEY=VALUE
if echo "$line" | grep -q '^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*:'; then
line="$(echo "$line" | sed -E 's/^([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*:[[:space:]]*/\1=/')"
fi
# 仅处理合法的 KEY=VALUE 形式
if echo "$line" | grep -q '^[A-Za-z_][A-Za-z0-9_]*='; then
# 去除等号两侧空白
line="$(echo "$line" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//; s/[[:space:]]*=[[:space:]]*/=/')"
export $line
fi
done < "$file"
else
echo "未找到 $file,继续使用当前环境变量" | tee -a $LOGFILE
fi
}
load_env_file "$ENV_FILE"
# 设置 NODE_ENV 为 development避免默认使用 production
export NODE_ENV="development"
# 打包之前,需要检查是否在 dev 分支,工作区是否干净,是否和远程分支一致
if [ "$(git branch --show-current)" != "$BRANCH_NAME" ]; then
echo "当前分支不是 dev 分支"

View File

@ -14,42 +14,6 @@ echo "Build process started at $(date)" | tee $LOGFILE
# 获取当前分支名
current_branch=$(git rev-parse --abbrev-ref HEAD)
# 指定并加载环境变量文件prod 使用 .env.production
ENV_FILE=".env.production"
# 兼容 KEY=VALUE 与 KEY: VALUE 的 .env 行为,忽略注释与空行
load_env_file() {
local file="$1"
if [ -f "$file" ]; then
echo "Loading environment from $file" | tee -a $LOGFILE
while IFS= read -r raw || [ -n "$raw" ]; do
# 去除注释与首尾空白
local line="${raw%%#*}"
line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
[ -z "$line" ] && continue
# 将 KEY: VALUE 转换为 KEY=VALUE
if echo "$line" | grep -q '^[A-Za-z_][A-Za-z0-9_]*[[:space:]]*:'; then
line="$(echo "$line" | sed -E 's/^([A-Za-z_][A-Za-z0-9_]*)[[:space:]]*:[[:space:]]*/\1=/')"
fi
# 仅处理合法的 KEY=VALUE 形式
if echo "$line" | grep -q '^[A-Za-z_][A-Za-z0-9_]*='; then
# 去除等号两侧空白
line="$(echo "$line" | sed -E 's/^[[:space:]]*//; s/[[:space:]]*$//; s/[[:space:]]*=[[:space:]]*/=/')"
export $line
fi
done < "$file"
else
echo "未找到 $file,继续使用当前环境变量" | tee -a $LOGFILE
fi
}
load_env_file "$ENV_FILE"
# 设置 NODE_ENV 为 production
export NODE_ENV="production"
# 打包之前,需要检查是否在 prod 分支,工作区是否干净,是否和远程分支一致
if [ "$(git branch --show-current)" != "$BRANCH_NAME" ]; then
echo "当前分支不是 prod 分支"