3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-06-19 06:43:41 +00:00

Slightly improve docs

This commit is contained in:
Arpad Borsos 2023-08-02 12:46:45 +02:00
parent f6987ea139
commit 3312b3ab47
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
7 changed files with 126 additions and 114 deletions

View file

@ -1,7 +1,7 @@
import * as buildjetCache from "@actions/buildjet-cache";
import * as ghCache from "@actions/cache";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import * as buildjetCache from "@actions/buildjet-cache";
import * as ghCache from "@actions/cache";
export function reportError(e: any) {
const { commandFailed } = e;
@ -43,16 +43,21 @@ export async function getCmdOutput(
return stdout;
}
export function getCacheHandler() {
const cacheProvider = core.getInput("cache-provider");
switch (cacheProvider) {
case "github":
core.info("Using Github Cache.");
return ghCache;
case "buildjet":
core.info("Using Buildjet Cache.");
return buildjetCache;
default:
throw new Error("Only currently support github and buildjet caches");
}
export interface CacheProvider {
name: string;
cache: typeof ghCache;
}
export function getCacheProvider(): CacheProvider {
const cacheProvider = core.getInput("cache-provider");
const cache = cacheProvider === "github" ? ghCache : cacheProvider === "buildjet" ? buildjetCache : undefined;
if (!cache) {
throw new Error(`The \`cache-provider\` \`{cacheProvider}\` is not valid.`);
}
return {
name: cacheProvider,
cache: cache,
};
}