(instance: Telemetry)
| 137 | const exitInstances = new Set<Telemetry>(); |
| 138 | let exitListenerRegistered = false; |
| 139 | function registerForExit(instance: Telemetry): void { |
| 140 | exitInstances.add(instance); |
| 141 | if (!exitListenerRegistered) { |
| 142 | exitListenerRegistered = true; |
| 143 | // 'exit' fires under process.exit() too (unlike beforeExit); handlers must |
| 144 | // be synchronous — persistSync is a single small file write. |
| 145 | process.on('exit', () => { |
| 146 | for (const i of exitInstances) i.persistSync(); |
| 147 | }); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | export class Telemetry { |
| 152 | private readonly dir: string; |
no test coverage detected