(output: string)
| 229 | |
| 230 | |
| 231 | export 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 | |
| 257 | function writePlist(plistPath: string, plan: InstallPlan, logPath: string): void { |
| 258 | const xml = buildLaunchAgentPlist({ |
no outgoing calls
no test coverage detected