feat: clean version

This commit is contained in:
xHyroM 2022-07-12 08:39:36 +02:00
parent 705032ffe3
commit ad6ee5950c
4 changed files with 14 additions and 18 deletions

View File

@ -17,7 +17,7 @@ const main = async() => {
const release = await getGithubRelease(version, token);
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);

View File

@ -13,20 +13,11 @@ export default (assets: Asset[]) => {
throw new Error(`Unsupported architechture ${process.arch}.`);
}
let platform;
switch (process.platform) {
case 'linux':
platform = 'linux'
break;
case 'darwin':
platform = 'darwin'
break;
default:
if (!['linux', 'darwin'].some(platform => process.platform === platform))
throw new Error(`Unsupported platform ${process.platform}.`);
}
return {
name: `bun-${platform}-${arch}.zip`,
asset: assets.find(asset => asset.name === `bun-${platform}-${arch}.zip`),
name: `bun-${process.platform}-${arch}.zip`,
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
}
}

View File

@ -9,7 +9,8 @@ export interface Release {
html_url: string;
tag_name: string;
message?: string;
assets: Asset[]
assets: Asset[];
version: string;
}
export default async(version: string, token: string): Promise<Release> => {
@ -25,5 +26,8 @@ export default async(version: string, token: string): Promise<Release> => {
}
})).json();
return release;
return {
...release,
version: release.tag_name.replace('bun-v', '')
};
}

View File

@ -6,7 +6,8 @@ import getHomeDir from './getHomeDir.js';
import { join } from 'path';
export default async(release: Release) => {
const cache = find('bun', release.tag_name);
const cache = find('bun', release.version);
console.log(cache);
if (cache) {
info(`Using cached Bun installation from ${cache}.`);
addPath(cache);
@ -23,7 +24,7 @@ export default async(release: Release) => {
const newCache = await cacheDir(
extracted,
'bun',
release.tag_name
release.version
);
info(`Cached Bun to ${newCache}.`);