Write pr-diff-range JSON file
This commit is contained in:
parent
1c15a48f3f
commit
77bc2a595e
2 changed files with 35 additions and 6 deletions
27
src/diff-filtering-utils.ts
Normal file
27
src/diff-filtering-utils.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { Logger } from "./logging";
|
||||
|
||||
export interface DiffThunkRange {
|
||||
path: string;
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
}
|
||||
|
||||
function getDiffRangesJsonFilePath(): string {
|
||||
return path.join(actionsUtil.getTemporaryDirectory(), "pr-diff-range.json");
|
||||
}
|
||||
|
||||
export function writeDiffRangesJsonFile(
|
||||
logger: Logger,
|
||||
ranges: DiffThunkRange[],
|
||||
): void {
|
||||
const jsonContents = JSON.stringify(ranges, null, 2);
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
fs.writeFileSync(jsonFilePath, jsonContents);
|
||||
logger.debug(
|
||||
`Wrote pr-diff-range JSON file to ${jsonFilePath}:\n${jsonContents}`,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue