Remove PromiseReturnType, add matchedKey == primaryKey check

This commit is contained in:
dhvcc 2022-04-03 18:52:43 +03:00
parent fa50ad5388
commit 08415fd28f
4 changed files with 9 additions and 24 deletions

View file

@ -1,6 +1,5 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {PromiseReturnType} from '../utils';
export enum State {
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
@ -42,19 +41,16 @@ abstract class CacheDistributor {
restoreKey
);
this.handleMatchResult(matchedKey);
this.handleMatchResult(matchedKey, primaryKey);
}
public handleMatchResult(
matchedKey: PromiseReturnType<typeof cache.restoreCache>
) {
if (matchedKey) {
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
if (matchedKey == primaryKey) {
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
core.info(`Cache restored from key: ${matchedKey}`);
} else {
core.info(`${this.packageManager} cache is not found`);
}
core.info('cache was hit');
core.setOutput('cache-hit', Boolean(matchedKey));
}
}