mirror of
https://github.com/actions/cache.git
synced 2025-04-21 19:46:46 +00:00
update save as well
This commit is contained in:
parent
d95c048983
commit
ac8fc97c06
12 changed files with 700 additions and 569 deletions
42
src/stateProvider.ts
Normal file
42
src/stateProvider.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import { State } from "./constants";
|
||||
|
||||
export interface IStateProvider {
|
||||
//setOutput(key: string, value: string): void;
|
||||
setState(key: string, value: string): void;
|
||||
getState(key: string): string;
|
||||
|
||||
getCacheState(): string | undefined;
|
||||
}
|
||||
|
||||
class StateProviderBase implements IStateProvider {
|
||||
getCacheState(): string | undefined {
|
||||
const cacheKey = this.getState(State.CacheMatchedKey);
|
||||
if (cacheKey) {
|
||||
core.debug(`Cache state/key: ${cacheKey}`);
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
||||
setState = (key: string, value: string) => {};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getState = (key: string) => "";
|
||||
}
|
||||
|
||||
export class StateProvider extends StateProviderBase {
|
||||
//setOutput = core.setOutput;
|
||||
setState = core.saveState;
|
||||
getState = core.getState;
|
||||
}
|
||||
|
||||
export class NullStateProvider extends StateProviderBase {
|
||||
//setOutput = core.setOutput;
|
||||
setState = core.setOutput;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getState = (key: string) => "";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue