forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.ts
More file actions
26 lines (24 loc) · 741 Bytes
/
Copy pathparser.ts
File metadata and controls
26 lines (24 loc) · 741 Bytes
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
import axios from "axios";
import { HTMLElement, parse } from "node-html-parser";
interface GitParser {
owner: string;
repo: string;
issue_number: number;
}
export const gitIssueParser = async ({ owner, repo, issue_number }: GitParser): Promise<boolean> => {
try {
const { data } = await axios.get(`https://github.com/${owner}/${repo}/issues/${issue_number}`);
const dom = parse(data);
const devForm = dom.querySelector("[data-target='create-branch.developmentForm']") as HTMLElement;
const linkedPRs = devForm.querySelectorAll(".my-1");
if (linkedPRs.length > 0) {
//has LinkedPRs
return true;
} else {
//no LinkedPRs
return false;
}
} catch (error) {
return true;
}
};