(raw: string)
| 115 | * we treat such a lockfile as "process is unknown version, refuse to share." |
| 116 | */ |
| 117 | export function decodeLockInfo(raw: string): DaemonLockInfo | null { |
| 118 | const trimmed = raw.trim(); |
| 119 | if (!trimmed) return null; |
| 120 | try { |
| 121 | const parsed = JSON.parse(trimmed); |
| 122 | if ( |
| 123 | parsed && |
| 124 | typeof parsed.pid === 'number' && |
| 125 | typeof parsed.version === 'string' && |
| 126 | typeof parsed.socketPath === 'string' && |
| 127 | typeof parsed.startedAt === 'number' |
| 128 | ) { |
| 129 | return parsed as DaemonLockInfo; |
| 130 | } |
| 131 | return null; |
| 132 | } catch { |
| 133 | // Fall through to legacy plain-pid handling. |
| 134 | } |
| 135 | const pid = Number(trimmed); |
| 136 | if (Number.isFinite(pid) && pid > 0) { |
| 137 | return { pid, version: 'unknown', socketPath: '', startedAt: 0 }; |
| 138 | } |
| 139 | return null; |
| 140 | } |
no outgoing calls
no test coverage detected