From e74422b4d844b43172b76216fa5e79b7be528dd8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 12 Nov 2020 10:37:04 +0100 Subject: [PATCH] backend-common: make ReadTreeResponse.files async --- packages/backend-common/src/reading/GithubUrlReader.test.ts | 2 +- packages/backend-common/src/reading/GithubUrlReader.ts | 2 +- packages/backend-common/src/reading/types.ts | 2 +- plugins/techdocs-backend/src/helpers.test.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/backend-common/src/reading/GithubUrlReader.test.ts b/packages/backend-common/src/reading/GithubUrlReader.test.ts index 1e7326af2b..7552547924 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.test.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.test.ts @@ -272,7 +272,7 @@ describe('GithubUrlReader', () => { ['mkdocs.yml', 'docs'], ); - const files = response.files(); + const files = await response.files(); const mkDocsFile = await files[0].content(); const indexMarkdownFile = await files[1].content(); diff --git a/packages/backend-common/src/reading/GithubUrlReader.ts b/packages/backend-common/src/reading/GithubUrlReader.ts index 906076a3c2..41db541f7f 100644 --- a/packages/backend-common/src/reading/GithubUrlReader.ts +++ b/packages/backend-common/src/reading/GithubUrlReader.ts @@ -286,7 +286,7 @@ export class GithubUrlReader implements UrlReader { // @ts-ignore Typescript doesn't consider .pipe a method on ReadableStream. Don't know why. repoArchive.body?.pipe(parser).on('finish', () => { resolve({ - files: () => { + files: async () => { return files; }, archive: () => { diff --git a/packages/backend-common/src/reading/types.ts b/packages/backend-common/src/reading/types.ts index 26ac4af45e..d9fa5d839e 100644 --- a/packages/backend-common/src/reading/types.ts +++ b/packages/backend-common/src/reading/types.ts @@ -49,7 +49,7 @@ export type File = { }; export type ReadTreeResponse = { - files(): File[]; + files(): Promise; archive(): Promise; dir(outDir?: string): Promise; }; diff --git a/plugins/techdocs-backend/src/helpers.test.ts b/plugins/techdocs-backend/src/helpers.test.ts index 8d4d69ba26..c3f2261637 100644 --- a/plugins/techdocs-backend/src/helpers.test.ts +++ b/plugins/techdocs-backend/src/helpers.test.ts @@ -30,7 +30,7 @@ describe('getDocFilesFromRepository', () => { dir: async () => { return '/tmp/testfolder'; }, - files: () => { + files: async () => { return []; }, archive: async () => { @@ -78,7 +78,7 @@ describe('getDocFilesFromRepository', () => { dir: async () => { return '/tmp/testfolder'; }, - files: () => { + files: async () => { return []; }, archive: async () => {