(filePath, content)
| 82 | // ─── Atomic writes ─────────────────────────────────────────────────────────── |
| 83 | |
| 84 | function writeAtomic(filePath, content) { |
| 85 | fs.mkdirSync(path.dirname(filePath), { recursive: true }); |
| 86 | const tmp = filePath + '.' + crypto.randomBytes(4).toString('hex') + '.tmp'; |
| 87 | fs.writeFileSync(tmp, content, { mode: FILE_MODE }); |
| 88 | fs.renameSync(tmp, filePath); |
| 89 | } |
| 90 | |
| 91 | function appendJsonl(filePath, obj) { |
| 92 | fs.mkdirSync(path.dirname(filePath), { recursive: true }); |