( pluginSlug: string, outputDir: string, )
| 134 | } |
| 135 | |
| 136 | export async function readRunnerResults( |
| 137 | pluginSlug: string, |
| 138 | outputDir: string, |
| 139 | ): Promise<RunnerResult | null> { |
| 140 | const cachePath = getRunnerOutputsPath(pluginSlug, outputDir); |
| 141 | if (await fileExists(cachePath)) { |
| 142 | const cachedResult = await readJsonFile<AuditOutputs>(cachePath); |
| 143 | logger.info( |
| 144 | `Read runner output from cache ${formatCachePathSuffix(cachePath)}`, |
| 145 | ); |
| 146 | return { |
| 147 | audits: cachedResult, |
| 148 | duration: 0, |
| 149 | date: new Date().toISOString(), |
| 150 | }; |
| 151 | } |
| 152 | logger.info( |
| 153 | `Cached runner output is not available ${formatCachePathSuffix(cachePath)}`, |
| 154 | ); |
| 155 | return null; |
| 156 | } |
| 157 | |
| 158 | function formatCachePathSuffix(cacheFilePath: string): string { |
| 159 | return ansis.gray(`(${cacheFilePath})`); |
no test coverage detected