diff options
Diffstat (limited to 'cgithub')
| -rw-r--r-- | cgithub/src/scraper.test.ts | 25 | ||||
| -rw-r--r-- | cgithub/src/scraper.ts | 5 |
2 files changed, 15 insertions, 15 deletions
diff --git a/cgithub/src/scraper.test.ts b/cgithub/src/scraper.test.ts index ad3ed46..1abab29 100644 --- a/cgithub/src/scraper.test.ts +++ b/cgithub/src/scraper.test.ts @@ -38,30 +38,27 @@ describe("GitHub scraper", () => { }); it("should fetch tree", async () => { - const data = await getGitHubTree("actions", "deploy-pages", "main", "src"); + const data = await getGitHubTree("github", "rally", "main", "lib"); - assert.strictEqual(data.repo.owner, "actions"); - assert.strictEqual(data.repo.name, "deploy-pages"); + assert.strictEqual(data.repo.owner, "github"); + assert.strictEqual(data.repo.name, "rally"); assert.strictEqual(data.branch, "main"); - assert.strictEqual(data.path, "src"); + assert.strictEqual(data.path, "lib"); assert.deepStrictEqual(data.items, [ { - name: "__tests__", - path: "src/__tests__", - contentType: "directory", - }, - { - name: "internal", - path: "src/internal", - contentType: "directory", + name: "README.md", + path: "lib/README.md", + contentType: "file", }, { - name: "index.js", - path: "src/index.js", + name: "RallyValidate.js", + path: "lib/RallyValidate.js", contentType: "file", }, ]); + + assert.ok(Object.keys(data.overviewHtml ?? {}).includes("README.md")); }); it("should fetch text blob", async () => { diff --git a/cgithub/src/scraper.ts b/cgithub/src/scraper.ts index ac30259..cd743a0 100644 --- a/cgithub/src/scraper.ts +++ b/cgithub/src/scraper.ts @@ -101,6 +101,7 @@ interface CodeViewRepoRoute { interface CodeViewTreeRoute { tree: { items: TreeItem[]; + readme?: OverviewFile; }; } @@ -416,7 +417,9 @@ export async function getGitHubTree( throw new Error("Could not find tree data in embedded JSON"); } - return extractGitHub(payload, { items: treeRoute.tree.items }); + const overviewHtml = extractOverviewHtml(treeRoute.tree.readme ? [treeRoute.tree.readme] : []); + + return extractGitHub(payload, { items: treeRoute.tree.items, overviewHtml }); } export async function getGitHubBlob( |
