()
| 106 | } |
| 107 | |
| 108 | private async readCacheFile(): Promise<CacheFileShape> { |
| 109 | try { |
| 110 | const raw = await readFile(this.cacheFilePath, 'utf8'); |
| 111 | const parsed = JSON.parse(raw) as Partial<CacheFileShape>; |
| 112 | if (parsed.version !== CACHE_SCHEMA_VERSION || !parsed.entries || typeof parsed.entries !== 'object') { |
| 113 | return emptyCacheFile(); |
| 114 | } |
| 115 | |
| 116 | return { |
| 117 | version: CACHE_SCHEMA_VERSION, |
| 118 | entries: parsed.entries, |
| 119 | }; |
| 120 | } catch { |
| 121 | return emptyCacheFile(); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | private async writeCacheFile(cache: CacheFileShape): Promise<void> { |
| 126 | await mkdir(dirname(this.cacheFilePath), { recursive: true }); |
no test coverage detected