Skip to content

Commit

Permalink
refactor: Optimize resource filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Mar 29, 2024
1 parent c2b323b commit be5da7f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/detectors/typeChecker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,19 @@ export class TsProjectDetector extends ProjectBasedDetector {

// Rewrite fs-paths to virtual paths
resourcePaths = [...allResources, ...allTestResources].map((res: Resource) => {
if (absoluteFilePaths.includes(res.getSourceMetadata().fsPath)) {
return res.getPath();
if (!absoluteFilePaths.includes(res.getSourceMetadata().fsPath)) {
return;
}

let resPath = res.getPath();
if (resPath.endsWith(".html")) {
resPath = resPath.replace(/\.[a-z]+$/, ".jsx");
} else if (!resPath.endsWith(".js")) {
resPath = resPath.replace(/\.[a-z]+$/, ".js");
}
return resPath;
})
.filter(($: string | undefined) => $)
.map((res) => {
if (res && res.endsWith(".html")) {
res = res.replace(/\.[a-z]+$/, ".jsx");
} else if (res && !res.endsWith(".js")) {
res = res.replace(/\.[a-z]+$/, ".js");
}
return res;
});
.filter(($: string | undefined) => $);
} else {
resourcePaths = Array.from(resources.keys());
}
Expand Down

0 comments on commit be5da7f

Please sign in to comment.