From c96926437cee66ead34c00fc904395615b775536 Mon Sep 17 00:00:00 2001 From: renxia Date: Tue, 14 May 2024 11:37:34 +0000 Subject: [PATCH] =?UTF-8?q?fix(update):=20=E4=BF=AE=E5=A4=8D=20update=20?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=20envConfig=20=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E5=A4=9A=E8=A1=8C=E5=8C=B9=E9=85=8D=E5=A4=84=E7=90=86=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/lib/update.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8893cfe..4c10098 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ }, "devDependencies": { "@lzwme/fed-lint-helper": "^2.6.0", - "@types/node": "^20.12.8", + "@types/node": "^20.12.12", "base64-js": "^1.5.1", "crypto-js": "^4.2.0", "husky": "^9.0.11", diff --git a/src/lib/update.ts b/src/lib/update.ts index 4542334..906e5e9 100644 --- a/src/lib/update.ts +++ b/src/lib/update.ts @@ -2,7 +2,7 @@ * @Author: renxia * @Date: 2024-01-11 13:38:34 * @LastEditors: renxia - * @LastEditTime: 2024-05-07 09:34:05 + * @LastEditTime: 2024-05-13 09:35:32 * @Description: */ import fs from 'node:fs'; @@ -77,7 +77,7 @@ export async function updateEnvConfigFile(envConfig: EnvConfig, updateEnvValue: const isExist = content.includes(`export ${name}=`); if (isExist) { - const oldValue = content.match(new RegExp(`export ${name}="(.*)"`))?.[1] || ''; + const oldValue = content.match(new RegExp(`export ${name}="([^"]+)"`))?.[1] || ''; if (oldValue.includes(value)) { logger.log(`[UpdateEnv]${color.cyan(name)} 已存在`, color.gray(value)); @@ -93,7 +93,7 @@ export async function updateEnvConfigFile(envConfig: EnvConfig, updateEnvValue: value = updateEnvValueByRegExp(/##([a-z0-9_\-*]+)/i, envConfig, value); } - content = content.replace(new RegExp(`export ${name}=.*`, 'g'), `export ${name}="${value}"`); + content = content.replace(`export ${name}="${oldValue}"`, `export ${name}="${value}"`); } else { if (desc) content += `\n# ${desc}`; content += `\nexport ${name}="${value}"`;