MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / parseLaunchctlPrint

Function parseLaunchctlPrint

packages/server/src/svc/launchd.ts:231–255  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

229
230
231export function parseLaunchctlPrint(output: string): {
232 state?: string;
233 pid?: number;
234 lastExitCode?: string;
235} {
236 const result: { state?: string; pid?: number; lastExitCode?: string } = {};
237 for (const rawLine of output.split(/\r?\n/)) {
238 const line = rawLine.trim();
239 const equalsIdx = line.indexOf('=');
240 if (equalsIdx === -1) continue;
241 const key = line.slice(0, equalsIdx).trim().toLowerCase();
242 const value = line.slice(equalsIdx + 1).trim();
243 if (key === 'state' && result.state === undefined) {
244 result.state = value;
245 } else if (key === 'pid' && result.pid === undefined) {
246 const n = Number.parseInt(value, 10);
247 if (Number.isFinite(n) && n > 0) {
248 result.pid = n;
249 }
250 } else if ((key === 'last exit code' || key === 'last exit status') && result.lastExitCode === undefined) {
251 result.lastExitCode = value;
252 }
253 }
254 return result;
255}
256
257function writePlist(plistPath: string, plan: InstallPlan, logPath: string): void {
258 const xml = buildLaunchAgentPlist({

Callers 2

launchd.test.tsFile · 0.90
statusFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected