mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-19 04:58:25 +02:00
fix: add .zip extension if it's not present
Workaround for https://github.com/actions/toolkit/issues/1179 Fixes https://github.com/oven-sh/setup-bun/issues/79
This commit is contained in:
parent
77ae1717ed
commit
f885433d15
2 changed files with 12 additions and 3 deletions
|
@ -13,7 +13,7 @@ import { downloadTool, extractZip } from "@actions/tool-cache";
|
||||||
import { getExecOutput } from "@actions/exec";
|
import { getExecOutput } from "@actions/exec";
|
||||||
import { writeBunfig } from "./bunfig";
|
import { writeBunfig } from "./bunfig";
|
||||||
import { saveState } from "@actions/core";
|
import { saveState } from "@actions/core";
|
||||||
import { retry } from "./utils";
|
import { addExtension, retry } from "./utils";
|
||||||
|
|
||||||
export type Input = {
|
export type Input = {
|
||||||
customUrl?: string;
|
customUrl?: string;
|
||||||
|
@ -119,7 +119,7 @@ async function downloadBun(
|
||||||
url: string,
|
url: string,
|
||||||
bunPath: string
|
bunPath: string
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
const zipPath = await downloadTool(url);
|
const zipPath = addExtension(await downloadTool(url), ".zip");
|
||||||
const extractedZipPath = await extractZip(zipPath);
|
const extractedZipPath = await extractZip(zipPath);
|
||||||
const extractedBunPath = await extractBun(extractedZipPath);
|
const extractedBunPath = await extractBun(extractedZipPath);
|
||||||
try {
|
try {
|
||||||
|
|
11
src/utils.ts
11
src/utils.ts
|
@ -1,6 +1,6 @@
|
||||||
import { debug, warning } from "@actions/core";
|
import { debug, warning } from "@actions/core";
|
||||||
import { info } from "node:console";
|
import { info } from "node:console";
|
||||||
import { existsSync, readFileSync } from "node:fs";
|
import { existsSync, readFileSync, renameSync } from "node:fs";
|
||||||
import { join, basename } from "node:path";
|
import { join, basename } from "node:path";
|
||||||
|
|
||||||
export function retry<T>(
|
export function retry<T>(
|
||||||
|
@ -18,6 +18,15 @@ export function retry<T>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addExtension(path: string, ext: string): string {
|
||||||
|
if (!path.endsWith(ext)) {
|
||||||
|
renameSync(path, path + ext);
|
||||||
|
return path + ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
const FILE_VERSION_READERS = {
|
const FILE_VERSION_READERS = {
|
||||||
"package.json": (content: string) =>
|
"package.json": (content: string) =>
|
||||||
JSON.parse(content).packageManager?.split("bun@")?.[1],
|
JSON.parse(content).packageManager?.split("bun@")?.[1],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue