blob: a73f7ee8bfbc0cc27ffd36ad9463298eb5035b60 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// macro code
export function matchInFile(callExpression) {
const [filePathNode, matcherNode] = callExpression.arguments;
const filePath: string = filePathNode.get();
const matcher: RegExp = matcherNode.get();
const file: string = Bun.readFile(Bun.cwd + filePath);
return (
<array>
{file
.split("\n")
.map((line) => line.match(matcher))
.filter(Boolean)
.reverse()
.map((line) => (
<string value={line[0]} />
))}
</array>
);
}
|