From f1c62fa190240f0785ca30280068c481ed4b6483 Mon Sep 17 00:00:00 2001 From: Alexu Date: Fri, 30 Jun 2023 17:56:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(@feflow/cli):=20=E4=BF=AE=E5=A4=8D=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=20feflow?= =?UTF-8?q?=20bin=20=E8=B7=AF=E5=BE=84=E8=A2=AB=E6=B3=A8=E9=87=8A=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E8=AF=AF=E5=88=A4=20(#436)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 被注释的 export feflow bin path 命令应判断为无效,并重新添加 --- packages/feflow-cli/src/core/universal-pkg/binp/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/feflow-cli/src/core/universal-pkg/binp/index.ts b/packages/feflow-cli/src/core/universal-pkg/binp/index.ts index 2be1a1be..f45b399f 100644 --- a/packages/feflow-cli/src/core/universal-pkg/binp/index.ts +++ b/packages/feflow-cli/src/core/universal-pkg/binp/index.ts @@ -3,6 +3,7 @@ import fs from 'fs'; import path from 'path'; import spawn from 'cross-spawn'; import osenv from 'osenv'; +import escapeRegExp from 'lodash/escapeRegExp'; /** * register the directory to the environment variable path @@ -101,8 +102,10 @@ export default class Binp { if (!fs.existsSync(profile)) { return profile; } - const content = fs.readFileSync(profile)?.toString(); - if (content?.indexOf(setStatement) === -1) { + const content = fs.readFileSync(profile)?.toString() || ''; + // 排除包含字符串但被注释的情况 + const setStatementRegExp = new RegExp(`(?