From a11484a419cb82951e57673a81390dd37196f8b2 Mon Sep 17 00:00:00 2001 From: xHyroM Date: Thu, 28 Jul 2022 09:12:02 +0200 Subject: [PATCH] chore: dont cache if customDownloadUrl --- dist/index.js | 2 +- dist/utils/install.js | 10 ++++++---- src/index.ts | 2 +- src/utils/install.ts | 11 +++++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index e366e02..31fb23c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -23,7 +23,7 @@ const main = async () => { if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found') return exit('Invalid bun version.', miscTestBuilds); info(`Going to install release ${release.version}`); - await install(release, token); + await install(release, token, customDownloadUrl === null); setOutput('bun-version', release.tag_name); } catch (e) { diff --git a/dist/utils/install.js b/dist/utils/install.js index 457770f..6bc07c0 100644 --- a/dist/utils/install.js +++ b/dist/utils/install.js @@ -5,7 +5,7 @@ import getAsset from './getAsset.js'; import { join } from 'path'; import { homedir } from 'os'; import { readdirSync } from 'fs'; -export default async (release, token) => { +export default async (release, token, customUrl) => { const asset = getAsset(release.assets); const path = join(homedir(), '.bun', 'bin', asset.name); const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`); @@ -21,9 +21,11 @@ export default async (release, token) => { const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin')); console.log(readdirSync(join(homedir(), '.bun', 'bin'))); const newCache = await cacheDir(extracted, 'bun', release.version); - await saveCache([ - join(extracted, asset.name) - ], `bun-${process.platform}-${asset.name}-${release.version}`); + if (!customUrl) { + await saveCache([ + join(extracted, asset.name) + ], `bun-${process.platform}-${asset.name}-${release.version}`); + } info(`Cached Bun to ${newCache}.`); addPath(newCache); const bunPath = join(homedir(), '.bun', 'bin', asset.name); diff --git a/src/index.ts b/src/index.ts index 4707ff8..8b6fdb9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,7 +26,7 @@ const main = async() => { info(`Going to install release ${release.version}`); - await install(release, token); + await install(release, token, customDownloadUrl === null); setOutput('bun-version', release.tag_name); } catch(e) { diff --git a/src/utils/install.ts b/src/utils/install.ts index 53d4477..57f8a84 100644 --- a/src/utils/install.ts +++ b/src/utils/install.ts @@ -7,7 +7,7 @@ import { join } from 'path'; import { homedir } from 'os'; import { readdirSync } from 'fs'; -export default async(release: Release, token: string) => { +export default async(release: Release, token: string, customUrl: boolean) => { const asset = getAsset(release.assets); const path = join(homedir(), '.bun', 'bin', asset.name); const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`); @@ -34,9 +34,12 @@ export default async(release: Release, token: string) => { 'bun', release.version ); - await saveCache([ - join(extracted, asset.name) - ], `bun-${process.platform}-${asset.name}-${release.version}`); + + if (!customUrl) { + await saveCache([ + join(extracted, asset.name) + ], `bun-${process.platform}-${asset.name}-${release.version}`); + } info(`Cached Bun to ${newCache}.`); addPath(newCache);