feat: 更新 .npmrc 文件以添加注释并简化 node 版本提取逻辑

This commit is contained in:
严浩
2024-10-12 15:46:48 +08:00
parent 4c23f82657
commit c7455bfb3c
2 changed files with 3 additions and 8 deletions

2
.npmrc
View File

@ -1 +1 @@
use-node-version=22.9.0
use-node-version=22.9.0 # https://pnpm.io/zh/npmrc#use-node-version

View File

@ -67,15 +67,10 @@ runs:
# Extract the node version from the .npmrc file
set -x;
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=$(sed -n 's/.*use-node-version=\([0-9.]*\).*/\1/p' .npmrc)
if [[ -z "$nodeVersion" ]]; then
nodeVersion="lts/*"
fi
echo "node-version=$nodeVersion" >> $GITHUB_OUTPUT
sed -i '/use-node-version/d' .npmrc
- uses: pnpm/action-setup@v4 # https://github.com/pnpm/action-setup?tab=readme-ov-file#inputs
if: steps.prepare.outputs.setup-pnpm == 'true'