Function
buildFileTree
(
files: Array<{ path: string; content: string; language: string }>,
)
Source from the content-addressed store, hash-verified
| 205 | } |
| 206 | |
| 207 | function buildFileTree( |
| 208 | files: Array<{ path: string; content: string; language: string }>, |
| 209 | ) { |
| 210 | const tree: any = {}; |
| 211 | |
| 212 | files.forEach((file) => { |
| 213 | const parts = file.path.split("/"); |
| 214 | let current = tree; |
| 215 | |
| 216 | parts.forEach((part, index) => { |
| 217 | if (!current[part]) { |
| 218 | current[part] = |
| 219 | index === parts.length - 1 ? { ...file, isFile: true } : {}; |
| 220 | } |
| 221 | current = current[part]; |
| 222 | }); |
| 223 | }); |
| 224 | |
| 225 | return tree; |
| 226 | } |
| 227 | |
| 228 | function FileTree({ |
| 229 | tree, |
Tested by
no test coverage detected