This commit is contained in:
Nathan Ahn 2025-07-12 13:27:44 -04:00
parent 11022e311a
commit 0c2abf5633
2 changed files with 5 additions and 3 deletions

2
dist/setup/index.js generated vendored

File diff suppressed because one or more lines are too long

View file

@ -53,7 +53,7 @@ export default async (options: Input): Promise<Output> => {
const cacheEnabled = isCacheEnabled(options); const cacheEnabled = isCacheEnabled(options);
const binPath = join(homedir(), ".bun", "bin"); const binPath = join(homedir(), ".bun", "bin");
const cachePath = join(homedir(), ".bun", "cache"); const cachePath = join(homedir(), ".bun", "install", "cache");
try { try {
mkdirSync(binPath, { recursive: true }); mkdirSync(binPath, { recursive: true });
} catch (error) { } catch (error) {
@ -75,6 +75,7 @@ export default async (options: Input): Promise<Output> => {
} }
let revision: string | undefined; let revision: string | undefined;
let cacheBaseHit = false;
let cacheHit = false; let cacheHit = false;
const cacheKeyBase = createHash("sha1").update(url).digest("base64") const cacheKeyBase = createHash("sha1").update(url).digest("base64")
@ -84,6 +85,7 @@ export default async (options: Input): Promise<Output> => {
if (cacheRestored) { if (cacheRestored) {
revision = await getRevision(bunPath); revision = await getRevision(bunPath);
if (revision) { if (revision) {
cacheBaseHit = true;
info(`Using a cached version of Bun: ${revision}`); info(`Using a cached version of Bun: ${revision}`);
if(cacheRestored === cacheKey){ if(cacheRestored === cacheKey){
info(`Cache hit with key: ${cacheRestored}`); info(`Cache hit with key: ${cacheRestored}`);
@ -97,7 +99,7 @@ export default async (options: Input): Promise<Output> => {
} }
} }
if (!cacheHit) { if (!cacheBaseHit) {
info(`Downloading a new version of Bun: ${url}`); info(`Downloading a new version of Bun: ${url}`);
// TODO: remove this, temporary fix for https://github.com/oven-sh/setup-bun/issues/73 // TODO: remove this, temporary fix for https://github.com/oven-sh/setup-bun/issues/73
revision = await retry(async () => await downloadBun(url, bunPath), 3); revision = await retry(async () => await downloadBun(url, bunPath), 3);