(options: {
stateDir: string;
session: string;
})
| 54 | }; |
| 55 | |
| 56 | export function readRemoteConnectionState(options: { |
| 57 | stateDir: string; |
| 58 | session: string; |
| 59 | }): RemoteConnectionState | null { |
| 60 | const statePath = remoteConnectionStatePath(options); |
| 61 | if (!fs.existsSync(statePath)) return null; |
| 62 | let parsed: unknown; |
| 63 | try { |
| 64 | parsed = JSON.parse(fs.readFileSync(statePath, 'utf8')); |
| 65 | } catch (error) { |
| 66 | removeInvalidRemoteConnectionState(options, error); |
| 67 | return null; |
| 68 | } |
| 69 | if (!isRemoteConnectionState(parsed)) { |
| 70 | removeInvalidRemoteConnectionState(options); |
| 71 | return null; |
| 72 | } |
| 73 | return parsed; |
| 74 | } |
| 75 | |
| 76 | export function writeRemoteConnectionState(options: { |
| 77 | stateDir: string; |
no test coverage detected