MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / getAllRoutes

Function getAllRoutes

src/devTools/allRoutes.ts:25–49  ·  view source on GitHub ↗
(root: string, path: string, routes: Route[])

Source from the content-addressed store, hash-verified

23};
24
25const 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};

Callers 1

getAllRemixRoutesFunction · 0.85

Calls 3

tryReadDirectoryFunction · 0.90
joinPathFunction · 0.90
generatePathFunction · 0.90

Tested by

no test coverage detected