(output: string)
| 322 | type ComposeContainer = { Name: string; Service: string; State: string }; |
| 323 | |
| 324 | function 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 | |
| 350 | async function listComposeContainers(): Promise<ComposeContainer[]> { |
| 351 | return new Promise<ComposeContainer[]>((resolve) => { |
no outgoing calls
no test coverage detected