Skip to content

Commit

Permalink
fix(@feflow/cli): 修复终端配置文件中 feflow bin 路径被注释时的误判
Browse files Browse the repository at this point in the history
被注释的 export feflow bin path 命令应判断为无效,并重新添加
  • Loading branch information
xqxian authored and alexqxxu committed Jun 30, 2023
1 parent 90577be commit 45dbf81
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/feflow-cli/src/core/universal-pkg/binp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(`(?<!#.*)${escapeRegExp(setStatement)}`);
if (!setStatementRegExp.test(content)) {
return profile;
}
this.handleUnsupportedTerminal(profile);
Expand Down

0 comments on commit 45dbf81

Please sign in to comment.