mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-19 03:27:20 +02:00
fix: handle missing readme
This commit is contained in:
@@ -103,6 +103,7 @@ export class GitHubRepository {
|
|||||||
if (selected && (!selected.readme || opt?.force === true)) {
|
if (selected && (!selected.readme || opt?.force === true)) {
|
||||||
// get the list of repo from github
|
// get the list of repo from github
|
||||||
const octokit = new Octokit({ auth: opt.accessToken });
|
const octokit = new Octokit({ auth: opt.accessToken });
|
||||||
|
try {
|
||||||
const ghRes = await octokit.repos.getReadme({
|
const ghRes = await octokit.repos.getReadme({
|
||||||
owner: this.owner,
|
owner: this.owner,
|
||||||
repo: this.repo,
|
repo: this.repo,
|
||||||
@@ -113,8 +114,10 @@ export class GitHubRepository {
|
|||||||
ghRes.data.encoding as BufferEncoding
|
ghRes.data.encoding as BufferEncoding
|
||||||
).toString("utf-8");
|
).toString("utf-8");
|
||||||
selected.readme = readme;
|
selected.readme = readme;
|
||||||
|
|
||||||
await model.save();
|
await model.save();
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error("readme_not_available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return selected.readme;
|
return selected.readme;
|
||||||
|
|||||||
Reference in New Issue
Block a user