(options: { stateDir: string; session: CliSessionRecord })
| 294 | } |
| 295 | |
| 296 | export function writeCliSession(options: { stateDir: string; session: CliSessionRecord }): void { |
| 297 | const filePath = resolveCliSessionPath(options.stateDir); |
| 298 | fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 }); |
| 299 | fs.writeFileSync(filePath, `${JSON.stringify(options.session, null, 2)}\n`, { |
| 300 | mode: 0o600, |
| 301 | }); |
| 302 | try { |
| 303 | fs.chmodSync(filePath, 0o600); |
| 304 | } catch { |
| 305 | // Best effort on filesystems that do not support POSIX mode bits. |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | export function removeCliSession(options: { stateDir: string }): boolean { |
| 310 | const filePath = resolveCliSessionPath(options.stateDir); |
no test coverage detected