( tree: RepoTree, folder: string, extension: string, depth: number, files = [] as RepoFile[], path = folder, )
| 123 | } |
| 124 | |
| 125 | export function getFolderFiles( |
| 126 | tree: RepoTree, |
| 127 | folder: string, |
| 128 | extension: string, |
| 129 | depth: number, |
| 130 | files = [] as RepoFile[], |
| 131 | path = folder, |
| 132 | ) { |
| 133 | if (depth <= 0) { |
| 134 | return files; |
| 135 | } |
| 136 | |
| 137 | Object.keys(tree[folder] || {}).forEach(key => { |
| 138 | if (extname(key)) { |
| 139 | const file = (tree[folder] as RepoTree)[key] as RepoFile; |
| 140 | if (!extension || key.endsWith(`.${extension}`)) { |
| 141 | files.unshift({ content: file.content, path: `${path}/${key}` }); |
| 142 | } |
| 143 | } else { |
| 144 | const subTree = tree[folder] as RepoTree; |
| 145 | return getFolderFiles(subTree, key, extension, depth - 1, files, `${path}/${key}`); |
| 146 | } |
| 147 | }); |
| 148 | |
| 149 | return files; |
| 150 | } |
| 151 | |
| 152 | export default class TestBackend implements Implementation { |
| 153 | mediaFolder: string; |
no outgoing calls
no test coverage detected