-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveMdEditComments.ts
More file actions
54 lines (45 loc) · 1.37 KB
/
removeMdEditComments.ts
File metadata and controls
54 lines (45 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import fs from "fs";
import { promisify } from "util";
const readFileAsync = promisify(fs.readFile);
const writeFileAsync = promisify(fs.writeFile);
const INPUT_FILE = "bugs.json";
const OUTPUT_FILE = "bugs.json";
interface Bug {
repo: string;
prNumber: number;
prTitle: string;
prLink: string;
commentAuthor: string;
commentBody: string;
commentBodyIncludesCodeSnippet: boolean;
commentLink: string;
filePath: string;
diffHunk: string;
line: number;
reactionCount: number;
timestamp: string;
isReviewComment: boolean;
pullRequestReviewId: number;
}
async function cleanupMdComments() {
try {
// Read the existing bugs
const data = await readFileAsync(INPUT_FILE, "utf8");
const bugs = JSON.parse(data) as Bug[];
console.log(`Found ${bugs.length} total bugs`);
// Filter out markdown-only comments
const filteredBugs = bugs.filter(
(bug: Bug) => !bug.filePath.toLowerCase().endsWith(".md")
);
console.log(
`Removed ${bugs.length - filteredBugs.length} markdown-only comments`
);
console.log(`Keeping ${filteredBugs.length} bugs`);
// Save the filtered bugs back to the file
await writeFileAsync(OUTPUT_FILE, JSON.stringify(filteredBugs, null, 2));
console.log("Successfully updated bugs.json");
} catch (error) {
console.error("Error processing bugs.json:", error);
}
}
cleanupMdComments();