From 2210d3ff3e70971419a8701812939433d4c531ff Mon Sep 17 00:00:00 2001 From: renxia Date: Mon, 13 May 2024 15:37:19 +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 --- src/lib/update.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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}"`;