25 lines
733 B
JavaScript
Executable file
25 lines
733 B
JavaScript
Executable file
|
|
const { Project, SyntaxKind } = require("ts-morph");
|
|
const fs = require("fs");
|
|
|
|
const project = new Project({ tsConfigFilePath: "./tsconfig.json" });
|
|
const sourceFile = project.getSourceFile("src/pages/Runboard.tsx");
|
|
let target;
|
|
|
|
sourceFile.forEachDescendant(node => {
|
|
if (node.getKind() === SyntaxKind.JsxOpeningElement) {
|
|
const attr = node.getAttribute("data-testid");
|
|
if (attr && attr.getText().includes("runboard-compare-remediation-route-banner")) {
|
|
target = node.getParent();
|
|
}
|
|
}
|
|
});
|
|
|
|
const bannerText = target.getText();
|
|
fs.writeFileSync("src/pages/temp_banner_test.tsx", `
|
|
import React from "react";
|
|
export const RunboardCompareRemediationRouteBanner = () => {
|
|
return (` + bannerText + `);
|
|
};
|
|
`);
|
|
|