(lockPath: string)
| 91 | } |
| 92 | |
| 93 | function readDaemonLockInfo(lockPath: string): DaemonLockInfo | null { |
| 94 | const data = readJsonFile(lockPath); |
| 95 | if (!data || typeof data !== 'object') return null; |
| 96 | const parsed = data as Partial<DaemonLockInfo>; |
| 97 | const hasPid = Number.isInteger(parsed.pid) && Number(parsed.pid) > 0; |
| 98 | if (!hasPid) { |
| 99 | return null; |
| 100 | } |
| 101 | return { |
| 102 | pid: Number(parsed.pid), |
| 103 | processStartTime: |
| 104 | typeof parsed.processStartTime === 'string' ? parsed.processStartTime : undefined, |
| 105 | startedAt: typeof parsed.startedAt === 'number' ? parsed.startedAt : undefined, |
| 106 | }; |
| 107 | } |
| 108 | |
| 109 | export function removeDaemonInfo(infoPath: string): void { |
| 110 | removeFileIfExists(infoPath); |
no test coverage detected