mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-02-23 10:40:10 +08:00
feat: clean version
This commit is contained in:
parent
705032ffe3
commit
ad6ee5950c
@ -17,7 +17,7 @@ const main = async() => {
|
|||||||
const release = await getGithubRelease(version, token);
|
const release = await getGithubRelease(version, token);
|
||||||
if (release?.message === 'Not Found') return exit('Invalid bun version.');
|
if (release?.message === 'Not Found') return exit('Invalid bun version.');
|
||||||
|
|
||||||
info(`Going to install release ${release.tag_name}`);
|
info(`Going to install release ${release.version}`);
|
||||||
|
|
||||||
await install(release);
|
await install(release);
|
||||||
|
|
||||||
|
@ -13,20 +13,11 @@ export default (assets: Asset[]) => {
|
|||||||
throw new Error(`Unsupported architechture ${process.arch}.`);
|
throw new Error(`Unsupported architechture ${process.arch}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let platform;
|
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||||
switch (process.platform) {
|
throw new Error(`Unsupported platform ${process.platform}.`);
|
||||||
case 'linux':
|
|
||||||
platform = 'linux'
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
|
||||||
platform = 'darwin'
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unsupported platform ${process.platform}.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: `bun-${platform}-${arch}.zip`,
|
name: `bun-${process.platform}-${arch}.zip`,
|
||||||
asset: assets.find(asset => asset.name === `bun-${platform}-${arch}.zip`),
|
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,8 @@ export interface Release {
|
|||||||
html_url: string;
|
html_url: string;
|
||||||
tag_name: string;
|
tag_name: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
assets: Asset[]
|
assets: Asset[];
|
||||||
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async(version: string, token: string): Promise<Release> => {
|
export default async(version: string, token: string): Promise<Release> => {
|
||||||
@ -25,5 +26,8 @@ export default async(version: string, token: string): Promise<Release> => {
|
|||||||
}
|
}
|
||||||
})).json();
|
})).json();
|
||||||
|
|
||||||
return release;
|
return {
|
||||||
|
...release,
|
||||||
|
version: release.tag_name.replace('bun-v', '')
|
||||||
|
};
|
||||||
}
|
}
|
@ -6,7 +6,8 @@ import getHomeDir from './getHomeDir.js';
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|
||||||
export default async(release: Release) => {
|
export default async(release: Release) => {
|
||||||
const cache = find('bun', release.tag_name);
|
const cache = find('bun', release.version);
|
||||||
|
console.log(cache);
|
||||||
if (cache) {
|
if (cache) {
|
||||||
info(`Using cached Bun installation from ${cache}.`);
|
info(`Using cached Bun installation from ${cache}.`);
|
||||||
addPath(cache);
|
addPath(cache);
|
||||||
@ -23,7 +24,7 @@ export default async(release: Release) => {
|
|||||||
const newCache = await cacheDir(
|
const newCache = await cacheDir(
|
||||||
extracted,
|
extracted,
|
||||||
'bun',
|
'bun',
|
||||||
release.tag_name
|
release.version
|
||||||
);
|
);
|
||||||
|
|
||||||
info(`Cached Bun to ${newCache}.`);
|
info(`Cached Bun to ${newCache}.`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user