Skip to content

Commit 2265e85

Browse files
committed
fix: exclude .d.ts files
1 parent 9d3fb3c commit 2265e85

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/const.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from "path";
22

33
export const ALLOW_EXT = ['.vue', '.js', '.ts'];
4+
export const TS_DECLARATION_EXT = '.d.ts';
45
export const UN_KNOWN = 'unknown';
56
export const IS_TOP_SCOPE = '[is_top_scope]';
67

src/utils/function_change/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import path from "path";
2-
import { ALLOW_EXT } from "../../const.js";
31
import { DiffInfo } from "../../type";
2+
import { isAllowExt } from "../handle_file_utils.js";
43
import { getFunctionDiffInfo } from "./diff.js";
54
import { getFileChange } from "./file_change.js";
65

@@ -13,7 +12,7 @@ export function diff () {
1312
const files = changedList[changeType];
1413

1514
for (const file of files) {
16-
if (!ALLOW_EXT.includes(path.extname(file))) continue;
15+
if (!isAllowExt(file)) continue;
1716

1817
result.push({
1918
file,

src/utils/handle_file_utils.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { visit } from 'recast';
44
import { parse } from '@babel/parser';
55
import { parseComponent, compile } from 'vue-template-compiler';
66
import lineByLine from 'n-readlines';
7-
import { ALLOW_EXT, IS_TOP_SCOPE, UN_KNOWN } from '../const.js';
7+
import { ALLOW_EXT, IS_TOP_SCOPE, TS_DECLARATION_EXT, UN_KNOWN } from '../const.js';
88
import {
99
AllFuncsInfo,
1010
FileAstInfo,
@@ -33,7 +33,7 @@ function getAllFiles (folderPath: string): string[] {
3333
const absolutePath = path.resolve(folderPath, files[i]);
3434

3535
if (fs.statSync(absolutePath).isFile()) {
36-
ALLOW_EXT.includes(path.extname(absolutePath)) && fileList.push(absolutePath);
36+
isAllowExt(absolutePath) && fileList.push(absolutePath);
3737
} else {
3838
dfs(absolutePath);
3939
}
@@ -457,9 +457,15 @@ function getVueScriptRealStartLine (filePath: string) {
457457
return 0;
458458
}
459459

460+
function isAllowExt (filePath: string) {
461+
return ALLOW_EXT.includes(path.extname(filePath)) && filePath.indexOf(TS_DECLARATION_EXT) === -1;
462+
}
463+
464+
460465
export {
461466
getFileInfo,
462467
getVueScriptRealStartLine,
463468
getFuncTree,
464469
getAllFiles,
470+
isAllowExt,
465471
};

0 commit comments

Comments
 (0)