From c7455bfb3c89f151207f8cd8cb62ba11ba0ac64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Sat, 12 Oct 2024 15:46:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20.npmrc=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BB=A5=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A=E5=B9=B6?= =?UTF-8?q?=E7=AE=80=E5=8C=96=20node=20=E7=89=88=E6=9C=AC=E6=8F=90?= =?UTF-8?q?=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmrc | 2 +- setup-node-environment/action.yml | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.npmrc b/.npmrc index e989a26..1b788bf 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -use-node-version=22.9.0 \ No newline at end of file +use-node-version=22.9.0 # https://pnpm.io/zh/npmrc#use-node-version \ No newline at end of file diff --git a/setup-node-environment/action.yml b/setup-node-environment/action.yml index af20e8e..10ff407 100644 --- a/setup-node-environment/action.yml +++ b/setup-node-environment/action.yml @@ -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'