({
version,
binaryTarget,
binaryName,
}: GetCachedBinaryOptions)
| 351 | } |
| 352 | |
| 353 | async function getCachedBinaryPath({ |
| 354 | version, |
| 355 | binaryTarget, |
| 356 | binaryName, |
| 357 | }: GetCachedBinaryOptions): Promise<string | null> { |
| 358 | const cacheDir = await getCacheDir(channel, version, binaryTarget) |
| 359 | if (!cacheDir) { |
| 360 | return null |
| 361 | } |
| 362 | |
| 363 | const cachedTargetPath = path.join(cacheDir, binaryName) |
| 364 | |
| 365 | if (!fs.existsSync(cachedTargetPath)) { |
| 366 | return null |
| 367 | } |
| 368 | |
| 369 | // All versions not called 'latest' are unique |
| 370 | // only latest needs more checks |
| 371 | if (version !== 'latest') { |
| 372 | return cachedTargetPath |
| 373 | } |
| 374 | |
| 375 | if (await exists(cachedTargetPath)) { |
| 376 | return cachedTargetPath |
| 377 | } |
| 378 | |
| 379 | return null |
| 380 | } |
| 381 | |
| 382 | type DownloadBinaryOptions = BinaryDownloadJob & { |
| 383 | version: string |
no test coverage detected