(lockFile)
| 606 | } |
| 607 | |
| 608 | function _readLockPayload(lockFile) { |
| 609 | try { |
| 610 | const raw = fs.readFileSync(lockFile, 'utf8').trim(); |
| 611 | if (!raw) return null; |
| 612 | // Backward-compat: older lock files contained only the pid as text. |
| 613 | // Newer payloads are JSON {pid, uid, startedAt}. |
| 614 | if (raw[0] === '{') { |
| 615 | try { return JSON.parse(raw); } catch (_) { return null; } |
| 616 | } |
| 617 | const pid = parseInt(raw, 10); |
| 618 | return Number.isFinite(pid) && pid > 0 ? { pid: pid } : null; |
| 619 | } catch (_) { return null; } |
| 620 | } |
| 621 | |
| 622 | function _lockPayload() { |
| 623 | return JSON.stringify({ |
no test coverage detected