feat: filter entry list from github before reading files (#868)
This commit is contained in:
committed by
GitHub
parent
f5f79b38f8
commit
ae5e261da5
@ -376,8 +376,8 @@ export default class GitGateway implements BackendClass {
|
||||
async entriesByFolder(folder: string, extension: string, depth: number) {
|
||||
return this.backend!.entriesByFolder(folder, extension, depth);
|
||||
}
|
||||
allEntriesByFolder(folder: string, extension: string, depth: number) {
|
||||
return this.backend!.allEntriesByFolder(folder, extension, depth);
|
||||
allEntriesByFolder(folder: string, extension: string, depth: number, pathRegex?: RegExp) {
|
||||
return this.backend!.allEntriesByFolder(folder, extension, depth, pathRegex);
|
||||
}
|
||||
entriesByFiles(files: ImplementationFile[]) {
|
||||
return this.backend!.entriesByFiles(files);
|
||||
|
@ -272,14 +272,18 @@ export default class GitHub implements BackendClass {
|
||||
return files;
|
||||
}
|
||||
|
||||
async allEntriesByFolder(folder: string, extension: string, depth: number) {
|
||||
async allEntriesByFolder(folder: string, extension: string, depth: number, pathRegex?: RegExp) {
|
||||
const repoURL = this.api!.originRepoURL;
|
||||
|
||||
const listFiles = () =>
|
||||
this.api!.listFiles(folder, {
|
||||
repoURL,
|
||||
depth,
|
||||
}).then(files => files.filter(file => filterByExtension(file, extension)));
|
||||
}).then(files =>
|
||||
files.filter(
|
||||
file => (!pathRegex || pathRegex.test(file.path)) && filterByExtension(file, extension),
|
||||
),
|
||||
);
|
||||
|
||||
const readFile = (path: string, id: string | null | undefined) => {
|
||||
return this.api!.readFile(path, id, { repoURL }) as Promise<string>;
|
||||
|
Reference in New Issue
Block a user