( tree: RepoTree, folder: string, extension: string, depth: number, files = [] as RepoFile[], path = folder, )
| 104 | } |
| 105 | |
| 106 | export function getFolderFiles( |
| 107 | tree: RepoTree, |
| 108 | folder: string, |
| 109 | extension: string, |
| 110 | depth: number, |
| 111 | files = [] as RepoFile[], |
| 112 | path = folder, |
| 113 | ) { |
| 114 | if (depth <= 0) { |
| 115 | return files; |
| 116 | } |
| 117 | |
| 118 | Object.keys(tree[folder] || {}).forEach(key => { |
| 119 | if (extname(key)) { |
| 120 | const file = (tree[folder] as RepoTree)[key] as RepoFile; |
| 121 | if (!extension || key.endsWith(`.${extension}`)) { |
| 122 | files.unshift({ content: file.content, path: `${path}/${key}` }); |
| 123 | } |
| 124 | } else { |
| 125 | const subTree = tree[folder] as RepoTree; |
| 126 | return getFolderFiles(subTree, key, extension, depth - 1, files, `${path}/${key}`); |
| 127 | } |
| 128 | }); |
| 129 | |
| 130 | return files; |
| 131 | } |
| 132 | |
| 133 | export default class TestBackend implements Implementation { |
| 134 | mediaFolder: string; |
no outgoing calls
no test coverage detected