MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / parseComposePsOutput

Function parseComposePsOutput

packages/setupWizard/src/index.ts:324–348  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

322type ComposeContainer = { Name: string; Service: string; State: string };
323
324function parseComposePsOutput(output: string): ComposeContainer[] {
325 const trimmed = output.trim();
326 if (!trimmed) {
327 return [];
328 }
329 if (trimmed.startsWith('[')) {
330 try {
331 return JSON.parse(trimmed) as ComposeContainer[];
332 } catch {
333 // fall through to line-based parse
334 }
335 }
336 const containers: ComposeContainer[] = [];
337 for (const line of trimmed.split('\n')) {
338 if (!line.trim()) {
339 continue;
340 }
341 try {
342 containers.push(JSON.parse(line) as ComposeContainer);
343 } catch {
344 // skip unparseable line
345 }
346 }
347 return containers;
348}
349
350async function listComposeContainers(): Promise<ComposeContainer[]> {
351 return new Promise<ComposeContainer[]>((resolve) => {

Callers 1

listComposeContainersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected