(path: string, html = false)
| 108 | } |
| 109 | |
| 110 | export function loadJsonFile<T>(path: string, html = false) { |
| 111 | const request = githubRequest(`repos/${owner}/${repo}/contents/${path}?ref=${branch}`); |
| 112 | if (html) { |
| 113 | request.headers.set('accept', GITHUB_ENCODING__HTML); |
| 114 | } |
| 115 | return githubFetch(request).then<FileContentsResponse | string>(response => { |
| 116 | if (response.status === 404) { |
| 117 | throw new Error(`Repo "${owner}/${repo}" does not have a file named "${path}" in the "${branch}" branch.`); |
| 118 | } |
| 119 | if (!response.ok) { |
| 120 | throw new Error(`Error fetching ${path}.`); |
| 121 | } |
| 122 | return html ? response.text() : response.json(); |
| 123 | }).then<T>(file => { |
| 124 | if (html) { |
| 125 | return file; |
| 126 | } |
| 127 | const { content } = file as FileContentsResponse; |
| 128 | const decoded = decodeBase64UTF8(content); |
| 129 | return JSON.parse(decoded); |
| 130 | }); |
| 131 | } |
| 132 | |
| 133 | export function loadIssueByTerm(term: string) { |
| 134 | const q = `"${term}" type:issue in:title repo:${owner}/${repo}`; |
no test coverage detected