MCPcopy Create free account
hub / github.com/coder/mux / findWorkspaces

Function findWorkspaces

src/cli/debug/git-status.ts:17–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15import { getMuxSrcDir } from "@/common/constants/paths";
16
17function findWorkspaces(): Array<{ id: string; path: string }> {
18 const workspaces: Array<{ id: string; path: string }> = [];
19 const muxSrcDir = getMuxSrcDir();
20
21 try {
22 const projects = readdirSync(muxSrcDir);
23 for (const project of projects) {
24 const projectPath = join(muxSrcDir, project);
25 if (!statSync(projectPath).isDirectory()) continue;
26
27 const branches = readdirSync(projectPath);
28 for (const branch of branches) {
29 const workspacePath = join(projectPath, branch);
30 if (statSync(workspacePath).isDirectory()) {
31 workspaces.push({
32 // NOTE: Using directory name as display ID for debug purposes only.
33 // This is NOT how workspace IDs are determined in production code.
34 // Production workspace IDs come from metadata.json in the session dir.
35 id: branch,
36 path: workspacePath,
37 });
38 }
39 }
40 }
41 } catch (err) {
42 console.error("Failed to find workspaces:", err);
43 }
44
45 return workspaces;
46}
47
48function testGitStatus(workspaceId: string, workspacePath: string) {
49 console.log("\n" + "=".repeat(80));

Callers 1

gitStatusCommandFunction · 0.85

Calls 2

getMuxSrcDirFunction · 0.90
pushMethod · 0.65

Tested by

no test coverage detected