mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
refactor(github): Platform-wide getJsonFile (#9383)
This commit is contained in:
parent
3915fa6512
commit
5928c8eb45
1 changed files with 10 additions and 11 deletions
|
@ -140,18 +140,17 @@ async function getBranchProtection(
|
||||||
return res.body;
|
return res.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getJsonFile(fileName: string): Promise<any | null> {
|
export async function getJsonFile(
|
||||||
|
fileName: string,
|
||||||
|
repo: string = config.repository
|
||||||
|
): Promise<any | null> {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(
|
const url = `repos/${repo}/contents/${fileName}`;
|
||||||
Buffer.from(
|
const res = await githubApi.getJson<{ content: string }>(url);
|
||||||
(
|
const buf = res.body.content;
|
||||||
await githubApi.getJson<{ content: string }>(
|
const str = Buffer.from(buf, 'base64').toString();
|
||||||
`repos/${config.repository}/contents/${fileName}`
|
const result = JSON.parse(str);
|
||||||
)
|
return result;
|
||||||
).body.content,
|
|
||||||
'base64'
|
|
||||||
).toString()
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue