mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-20 15:53:59 +08:00
Add initial eslint setup (#88)
This commit is contained in:
parent
31508256ff
commit
fb50aa45ec
12 changed files with 1044 additions and 91 deletions
|
@ -4,7 +4,6 @@ import * as fs from "fs";
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as uuidV4 from "uuid/v4";
|
||||
|
||||
import { Outputs, State } from "../constants";
|
||||
import { ArtifactCacheEntry } from "../contracts";
|
||||
|
||||
|
@ -50,10 +49,18 @@ export function isExactKeyMatch(
|
|||
);
|
||||
}
|
||||
|
||||
export function setCacheState(state: ArtifactCacheEntry): void {
|
||||
core.saveState(State.CacheResult, JSON.stringify(state));
|
||||
}
|
||||
|
||||
export function setCacheHitOutput(isCacheHit: boolean): void {
|
||||
core.setOutput(Outputs.CacheHit, isCacheHit.toString());
|
||||
}
|
||||
|
||||
export function setOutputAndState(
|
||||
key: string,
|
||||
cacheResult?: ArtifactCacheEntry
|
||||
) {
|
||||
): void {
|
||||
setCacheHitOutput(isExactKeyMatch(key, cacheResult));
|
||||
// Store the cache result if it exists
|
||||
cacheResult && setCacheState(cacheResult);
|
||||
|
@ -65,14 +72,6 @@ export function getCacheState(): ArtifactCacheEntry | undefined {
|
|||
return (stateData && JSON.parse(stateData)) as ArtifactCacheEntry;
|
||||
}
|
||||
|
||||
export function setCacheState(state: ArtifactCacheEntry) {
|
||||
core.saveState(State.CacheResult, JSON.stringify(state));
|
||||
}
|
||||
|
||||
export function setCacheHitOutput(isCacheHit: boolean) {
|
||||
core.setOutput(Outputs.CacheHit, isCacheHit.toString());
|
||||
}
|
||||
|
||||
export function resolvePath(filePath: string): string {
|
||||
if (filePath[0] === "~") {
|
||||
const home = os.homedir();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue