Filter alerts by pr-diff-range JSON file

This commit is contained in:
Chuan-kai Lin
2025-02-19 06:26:11 -08:00
parent 77bc2a595e
commit dae1626680
3 changed files with 74 additions and 0 deletions

View File

@@ -25,3 +25,18 @@ export function writeDiffRangesJsonFile(
`Wrote pr-diff-range JSON file to ${jsonFilePath}:\n${jsonContents}`,
);
}
export function readDiffRangesJsonFile(
logger: Logger,
): DiffThunkRange[] | undefined {
const jsonFilePath = getDiffRangesJsonFilePath();
if (!fs.existsSync(jsonFilePath)) {
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
return undefined;
}
const jsonContents = fs.readFileSync(jsonFilePath, "utf8");
logger.debug(
`Read pr-diff-range JSON file from ${jsonFilePath}:\n${jsonContents}`,
);
return JSON.parse(jsonContents) as DiffThunkRange[];
}