(dir: string)
| 74 | } |
| 75 | |
| 76 | async function cleanup(dir: string) { |
| 77 | const glob = new Bun.Glob("????-??-??T??????.log") |
| 78 | const files = await Array.fromAsync( |
| 79 | glob.scan({ |
| 80 | cwd: dir, |
| 81 | absolute: true, |
| 82 | }), |
| 83 | ) |
| 84 | if (files.length <= 5) return |
| 85 | |
| 86 | const filesToDelete = files.slice(0, -10) |
| 87 | await Promise.all(filesToDelete.map((file) => fs.unlink(file).catch(() => {}))) |
| 88 | } |
| 89 | |
| 90 | function formatError(error: Error, depth = 0): string { |
| 91 | const result = error.message |