8000 Remove PromiseReturnType, add matchedKey == primaryKey check · dhvcc/setup-python@08415fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 08415fd

Browse files
committed
Remove PromiseReturnType, add matchedKey == primaryKey check
1 parent fa50ad5 commit 08415fd

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

dist/cache-save/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37234,18 +37234,17 @@ class CacheDistributor {
3723437234
core.saveState(State.CACHE_PATHS, cachePath);
3723537235
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
3723637236
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
37237-
this.handleMatchResult(matchedKey);
37237+
this.handleMatchResult(matchedKey, primaryKey);
3723837238
});
3723937239
}
37240-
handleMatchResult(matchedKey) {
37241-
if (matchedKey) {
37240+
handleMatchResult(matchedKey, primaryKey) {
37241+
if (matchedKey == primaryKey) {
3724237242
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
3724337243
core.info(`Cache restored from key: ${matchedKey}`);
3724437244
}
3724537245
else {
3724637246
core.info(`${this.packageManager} cache is not found`);
3724737247
}
37248-
core.info('cache was hit');
3724937248
core.setOutput('cache-hit', Boolean(matchedKey));
3725037249
}
3725137250
}

dist/setup/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42579,18 +42579,17 @@ class CacheDistributor {
4257942579
core.saveState(State.CACHE_PATHS, cachePath);
4258042580
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
4258142581
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
42582-
this.handleMatchResult(matchedKey);
42582+
this.handleMatchResult(matchedKey, primaryKey);
4258342583
});
4258442584
}
42585-
handleMatchResult(matchedKey) {
42586-
if (matchedKey) {
42585+
handleMatchResult(matchedKey, primaryKey) {
42586+
if (matchedKey == primaryKey) {
4258742587
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
4258842588
core.info(`Cache restored from key: ${matchedKey}`);
4258942589
}
4259042590
else {
4259142591
core.info(`${this.packageManager} cache is not found`);
4259242592
}
42593-
core.info('cache was hit');
4259442593
core.setOutput('cache-hit', Boolean(matchedKey));
4259542594
}
4259642595
}

src/cache-distributions/cache-distributor.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as cache from '@actions/cache';
22
import * as core from '@actions/core';
3-
import {PromiseReturnType} from '../utils';
43

54
export enum State {
65
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
@@ -42,19 +41,16 @@ abstract class CacheDistributor {
4241
restoreKey
4342
);
4443

45-
this.handleMatchResult(matchedKey);
44+
this.handleMatchResult(matchedKey, primaryKey);
4645
}
4746

48-
public handleMatchResult(
49-
matchedKey: PromiseReturnType<typeof cache.restoreCache>
50-
) {
51-
if (matchedKey) {
47+
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
48+
if (matchedKey == primaryKey) {
5249
core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
5350
core.info(`Cache restored from key: ${matchedKey}`);
5451
} else {
5552
core.info(`${this.packageManager} cache is not found`);
5653
}
57-
core.info('cache was hit');
5854
core.setOutput('cache-hit', Boolean(matchedKey));
5955
}
6056
}

src/utils.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,3 @@ export function isCacheFeatureAvailable(): boolean {
119119

120120
return true;
121121
}
122-
123-
// Awaited (typescript 4.5+) polyfill. Not ideal, so use with care
124-
export type AwaitedPolyfill<T> = T extends PromiseLike<infer U>
125-
? AwaitedPolyfill<U>
126-
: T;
127-
// Extract return type from promise
128-
export type PromiseReturnType<
129-
T extends (...args: any) => any
130-
> = AwaitedPolyfill<ReturnType<T>>;

0 commit comments

Comments
 (0)
0