fix
This commit is contained in:
parent
b67f026fc2
commit
466b8e41d2
@ -16,7 +16,7 @@ import { getExecOutput } from "@actions/exec";
|
|||||||
import { Registry } from "./registry";
|
import { Registry } from "./registry";
|
||||||
import { writeBunfig } from "./bunfig";
|
import { writeBunfig } from "./bunfig";
|
||||||
import { saveState } from "@actions/core";
|
import { saveState } from "@actions/core";
|
||||||
import { addExtension, retry } from "./utils";
|
import { addExtension } from "./utils";
|
||||||
import { DownloadMeta, getDownloadMeta } from "./download-url";
|
import { DownloadMeta, getDownloadMeta } from "./download-url";
|
||||||
import { cwd } from "node:process";
|
import { cwd } from "node:process";
|
||||||
|
|
||||||
@ -110,11 +110,7 @@ export default async (options: Input): Promise<Output> => {
|
|||||||
|
|
||||||
if (!cacheHit) {
|
if (!cacheHit) {
|
||||||
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
|
revision = await downloadBun(downloadMeta, bunPath);
|
||||||
revision = await retry(
|
|
||||||
async () => await downloadBun(downloadMeta, bunPath),
|
|
||||||
3,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/utils.ts
15
src/utils.ts
@ -3,21 +3,6 @@ import { info } from "node:console";
|
|||||||
import { existsSync, readFileSync, renameSync } from "node:fs";
|
import { existsSync, readFileSync, renameSync } from "node:fs";
|
||||||
import { resolve, basename } from "node:path";
|
import { resolve, basename } from "node:path";
|
||||||
|
|
||||||
export function retry<T>(
|
|
||||||
fn: () => Promise<T>,
|
|
||||||
retries: number,
|
|
||||||
timeout = 10000,
|
|
||||||
): Promise<T> {
|
|
||||||
return fn().catch((err) => {
|
|
||||||
if (retries <= 0) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, timeout)).then(() =>
|
|
||||||
retry(fn, retries - 1, timeout),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function request(
|
export async function request(
|
||||||
url: string,
|
url: string,
|
||||||
init?: RequestInit,
|
init?: RequestInit,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user