( state: DaemonState, stateFile: string = resolveStateFilePath(), )
| 95 | } |
| 96 | |
| 97 | export function writeStateFile( |
| 98 | state: DaemonState, |
| 99 | stateFile: string = resolveStateFilePath(), |
| 100 | ): void { |
| 101 | fs.mkdirSync(path.dirname(stateFile), { recursive: true }); |
| 102 | const tmp = `${stateFile}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`; |
| 103 | fs.writeFileSync(tmp, JSON.stringify(state, null, 2), { mode: 0o600 }); |
| 104 | fs.renameSync(tmp, stateFile); |
| 105 | } |
| 106 | |
| 107 | export function removeStateFile(stateFile: string = resolveStateFilePath()): void { |
| 108 | try { |
no test coverage detected