(root: string, path: string, routes: Route[])
| 23 | }; |
| 24 | |
| 25 | const getAllRoutes = async (root: string, path: string, routes: Route[]) => { |
| 26 | try { |
| 27 | // Get all files in the current directory |
| 28 | const files = await tryReadDirectory(path); |
| 29 | |
| 30 | for (const [file, fileType] of files) { |
| 31 | const filePath = joinPath(vscode.Uri.file(path), file); |
| 32 | |
| 33 | if (fileType === vscode.FileType.File) { |
| 34 | const path = generatePath(filePath.path, undefined); |
| 35 | routes.push({ |
| 36 | url: path, |
| 37 | path: filePath.path.replace(root, ""), |
| 38 | }); |
| 39 | // If the current file is actually a directory we recursively keep generating routes |
| 40 | } else if (fileType === vscode.FileType.Directory) { |
| 41 | await getAllRoutes(root, filePath.path, routes); |
| 42 | // After we are done with the generation we delete the directory we are in recursively |
| 43 | await vscode.workspace.fs.delete(filePath, { recursive: true }); |
| 44 | } |
| 45 | } |
| 46 | } catch (err) { |
| 47 | return; |
| 48 | } |
| 49 | }; |
no test coverage detected