()
| 183 | * Read runner state from local file |
| 184 | */ |
| 185 | export async function readRunnerState(): Promise<RunnerLocallyPersistedState | null> { |
| 186 | try { |
| 187 | if (!existsSync(configuration.runnerStateFile)) { |
| 188 | return null; |
| 189 | } |
| 190 | const content = await readFile(configuration.runnerStateFile, 'utf-8'); |
| 191 | return JSON.parse(content) as RunnerLocallyPersistedState; |
| 192 | } catch (error) { |
| 193 | // State corrupted somehow :( |
| 194 | console.error(`[PERSISTENCE] Runner state file corrupted: ${configuration.runnerStateFile}`, error); |
| 195 | return null; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Write runner state to local file (synchronously for atomic operation) |
no test coverage detected