* Get all files in a folder * e.g /dir1/dir2/dir3 * This function will first test if dir1 exists in the tree, * if not, it will return null, otherwise it will traverse the tree * and return the files in dir3 * @param {string} path - Folder path * @param {Tree} tree - Files tree
(path, tree)
| 186 | * @param {Tree} tree - Files tree |
| 187 | */ |
| 188 | function getFile(path, tree) { |
| 189 | const { children } = tree; |
| 190 | let { url } = tree; |
| 191 | if (url === path) return tree; |
| 192 | if (!children) return null; |
| 193 | const len = children.length; |
| 194 | for (let i = 0; i < len; i++) { |
| 195 | const item = children[i]; |
| 196 | const result = getFile(path, item); |
| 197 | if (result) return result; |
| 198 | } |
| 199 | return null; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Get all files |
no outgoing calls
no test coverage detected