( lockFilePath: string, )
| 135 | * Read and parse a lock file's content |
| 136 | */ |
| 137 | export function readLockContent( |
| 138 | lockFilePath: string, |
| 139 | ): VersionLockContent | null { |
| 140 | const fs = getFsImplementation() |
| 141 | |
| 142 | try { |
| 143 | const content = fs.readFileSync(lockFilePath, { encoding: 'utf8' }) |
| 144 | if (!content || content.trim() === '') { |
| 145 | return null |
| 146 | } |
| 147 | |
| 148 | const parsed = jsonParse(content) as VersionLockContent |
| 149 | |
| 150 | // Validate required fields |
| 151 | if (typeof parsed.pid !== 'number' || !parsed.version || !parsed.execPath) { |
| 152 | return null |
| 153 | } |
| 154 | |
| 155 | return parsed |
| 156 | } catch { |
| 157 | return null |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Check if a lock file represents an active lock (process still running) |
no test coverage detected