(path: string, content: string)
| 121 | } |
| 122 | |
| 123 | private async _doAppendVersion(path: string, content: string): Promise<void> { |
| 124 | const dir = this.versionsDir(path); |
| 125 | await mkdir(dir, { recursive: true }); |
| 126 | const key = `${Date.now()}-${String(++_versionCounter).padStart(4, "0")}`; |
| 127 | await writeFile(join(dir, `${key}.html`), content, "utf8"); |
| 128 | // prune oldest beyond maxVersions |
| 129 | const all = (await readdir(dir)).filter((f) => f.endsWith(".html")).sort(); |
| 130 | const excess = all.length - this.maxVersions; |
| 131 | if (excess > 0) { |
| 132 | await Promise.all(all.slice(0, excess).map((f) => unlink(join(dir, f)).catch(() => {}))); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function isNotFound(err: unknown): boolean { |
no test coverage detected