Skip to content

Commit a937d78

Browse files
committed
feat: Simplify the path to the file where the function is located
1 parent be8a30a commit a937d78

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/impact.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'path';
12
import { TEXT_NODE_TYPES, UN_KNOWN } from './const.js';
23
import {
34
FileInfoTree,
@@ -21,9 +22,10 @@ function getImpacts (treeData: FileInfoTree, funcInfo: ImpactReason) {
2122
// function entrance
2223
const main = {
2324
name: funcInfo.name,
24-
file: funcInfo.filePath,
25+
file: path.relative(process.cwd(), funcInfo.filePath),
2526
position: mainFuncPosition,
2627
};
28+
funcInfo.paths[0][1] = path.relative(process.cwd(), funcInfo.paths[0][1]);
2729
funcInfo.paths[0].push(mainFuncPosition);
2830

2931
let callList = [funcInfo] as ImpactReason[];
@@ -96,7 +98,7 @@ function findWhoCallMe (treeData: FileInfoTree, funcInfo: ImpactReason, reportIn
9698

9799
// collect call paths
98100
const paths = [...curPaths];
99-
paths.push([func.name, func.filePath, func.position]);
101+
paths.push([func.name, path.relative(process.cwd(), func.filePath), func.position]);
100102

101103
theyCallYou.push({
102104
filePath: func.filePath,
@@ -130,7 +132,7 @@ function findWhoCallMe (treeData: FileInfoTree, funcInfo: ImpactReason, reportIn
130132
templateFragmentCache.push(cache);
131133

132134
reportInfo.push({
133-
filePath: treeData[fileInfo].file,
135+
filePath: path.relative(process.cwd(), treeData[fileInfo].file),
134136
domInfo
135137
});
136138
}

0 commit comments

Comments
 (0)