MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseWorkspaceStatus

Function parseWorkspaceStatus

src/utils/citcWorkspaceSource.ts:71–101  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

69}
70
71export function parseWorkspaceStatus(output: string): {
72 rawWorkspaceName: string | null
73 workspaceVersion: number | null
74 workspaceState: string | null
75} {
76 const lines = output.split(/\r?\n/u).map(line => line.trim())
77 const rawWorkspaceName =
78 lines
79 .find(line => line.startsWith('Raw Workspace Name: '))
80 ?.slice('Raw Workspace Name: '.length)
81 .trim() || null
82 const workspaceState =
83 lines
84 .find(line => line.startsWith('Workspace State: '))
85 ?.slice('Workspace State: '.length)
86 .trim() || null
87 const versionText =
88 lines
89 .find(line => line.startsWith('Workspace Version: '))
90 ?.slice('Workspace Version: '.length)
91 .trim() || null
92
93 const parsedVersion =
94 versionText && /^\d+$/u.test(versionText) ? Number(versionText) : null
95
96 return {
97 rawWorkspaceName,
98 workspaceVersion: parsedVersion,
99 workspaceState,
100 }
101}
102
103async function readTextIfExists(path: string): Promise<string | null> {
104 try {

Calls

no outgoing calls

Tested by

no test coverage detected