feat: 在 action.yml 中添加对 .npmrc 文件存在性的检查,以确保正确提取 Node 版本

This commit is contained in:
严浩
2024-10-12 15:36:43 +08:00
parent 55c4c305c0
commit 1fcbdefb2f

View File

@ -68,7 +68,9 @@ runs:
# Extract the node version from the .npmrc file
set -x;
nodeVersion=$(grep 'use-node-version=' .npmrc | sed -E 's/^use-node-version=([0-9.]+).*/\1/')
if [ -f ".npmrc" ]; then
nodeVersion=$(grep 'use-node-version=' .npmrc | sed -E 's/^use-node-version=([0-9.]+).*/\1/')
fi
if [ -z "$nodeVersion" ]; then
nodeVersion="lts/*"
fi