1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-06-21 04:00:22 +02:00

Update non-null state provider to also output primary/matched keys

This commit is contained in:
Stuart Leeks 2025-05-08 16:51:55 +00:00
parent 480d890516
commit 91afe36e0a
4 changed files with 51 additions and 33 deletions

View file

@ -21,26 +21,28 @@ class StateProviderBase implements IStateProvider {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
setState = (key: string, value: string) => {};
setState = (key: string, value: string) => { };
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getState = (key: string) => "";
}
export class StateProvider extends StateProviderBase {
setState = core.saveState;
setState = (key: string, value: string) => { core.saveState(key, value); stateToOutput(key, value); };
getState = core.getState;
}
const stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
function stateToOutput(key: string, value: string) {
core.setOutput(stateToOutputMap.get(key) as string, value);
}
export class NullStateProvider extends StateProviderBase {
stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
setState = (key: string, value: string) => {
core.setOutput(this.stateToOutputMap.get(key) as string, value);
};
setState = stateToOutput;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getState = (key: string) => "";
}