chore: dont cache if customDownloadUrl

This commit is contained in:
xHyroM 2022-07-28 09:12:02 +02:00
parent fe160cf381
commit a11484a419
4 changed files with 15 additions and 10 deletions

2
dist/index.js vendored
View File

@ -23,7 +23,7 @@ const main = async () => {
if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found')
return exit('Invalid bun version.', miscTestBuilds);
info(`Going to install release ${release.version}`);
await install(release, token);
await install(release, token, customDownloadUrl === null);
setOutput('bun-version', release.tag_name);
}
catch (e) {

10
dist/utils/install.js vendored
View File

@ -5,7 +5,7 @@ import getAsset from './getAsset.js';
import { join } from 'path';
import { homedir } from 'os';
import { readdirSync } from 'fs';
export default async (release, token) => {
export default async (release, token, customUrl) => {
const asset = getAsset(release.assets);
const path = join(homedir(), '.bun', 'bin', asset.name);
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
@ -21,9 +21,11 @@ export default async (release, token) => {
const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin'));
console.log(readdirSync(join(homedir(), '.bun', 'bin')));
const newCache = await cacheDir(extracted, 'bun', release.version);
await saveCache([
join(extracted, asset.name)
], `bun-${process.platform}-${asset.name}-${release.version}`);
if (!customUrl) {
await saveCache([
join(extracted, asset.name)
], `bun-${process.platform}-${asset.name}-${release.version}`);
}
info(`Cached Bun to ${newCache}.`);
addPath(newCache);
const bunPath = join(homedir(), '.bun', 'bin', asset.name);

View File

@ -26,7 +26,7 @@ const main = async() => {
info(`Going to install release ${release.version}`);
await install(release, token);
await install(release, token, customDownloadUrl === null);
setOutput('bun-version', release.tag_name);
} catch(e) {

View File

@ -7,7 +7,7 @@ import { join } from 'path';
import { homedir } from 'os';
import { readdirSync } from 'fs';
export default async(release: Release, token: string) => {
export default async(release: Release, token: string, customUrl: boolean) => {
const asset = getAsset(release.assets);
const path = join(homedir(), '.bun', 'bin', asset.name);
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
@ -34,9 +34,12 @@ export default async(release: Release, token: string) => {
'bun',
release.version
);
await saveCache([
join(extracted, asset.name)
], `bun-${process.platform}-${asset.name}-${release.version}`);
if (!customUrl) {
await saveCache([
join(extracted, asset.name)
], `bun-${process.platform}-${asset.name}-${release.version}`);
}
info(`Cached Bun to ${newCache}.`);
addPath(newCache);