From fa50ad538807f67c405fa3aa67683425a2488d4d Mon Sep 17 00:00:00 2001
From: dhvcc <1337kwiz@gmail.com>
Date: Sun, 3 Apr 2022 02:47:14 +0300
Subject: [PATCH] Build action with cache-hit output

---
 dist/cache-save/index.js                     | 19 ++++++++++++-------
 dist/setup/index.js                          | 19 ++++++++++++-------
 src/cache-distributions/cache-distributor.ts |  1 +
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js
index bf48c7a6..478fd5ed 100644
--- a/dist/cache-save/index.js
+++ b/dist/cache-save/index.js
@@ -37234,15 +37234,20 @@ class CacheDistributor {
             core.saveState(State.CACHE_PATHS, cachePath);
             core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
             const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
-            if (matchedKey) {
-                core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
-                core.info(`Cache restored from key: ${matchedKey}`);
-            }
-            else {
-                core.info(`${this.packageManager} cache is not found`);
-            }
+            this.handleMatchResult(matchedKey);
         });
     }
+    handleMatchResult(matchedKey) {
+        if (matchedKey) {
+            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));
+    }
 }
 exports.default = CacheDistributor;
 
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 1c8512e0..fc44f28d 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -42579,15 +42579,20 @@ class CacheDistributor {
             core.saveState(State.CACHE_PATHS, cachePath);
             core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
             const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
-            if (matchedKey) {
-                core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
-                core.info(`Cache restored from key: ${matchedKey}`);
-            }
-            else {
-                core.info(`${this.packageManager} cache is not found`);
-            }
+            this.handleMatchResult(matchedKey);
         });
     }
+    handleMatchResult(matchedKey) {
+        if (matchedKey) {
+            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));
+    }
 }
 exports.default = CacheDistributor;
 
diff --git a/src/cache-distributions/cache-distributor.ts b/src/cache-distributions/cache-distributor.ts
index 3b30076c..c939ec2e 100644
--- a/src/cache-distributions/cache-distributor.ts
+++ b/src/cache-distributions/cache-distributor.ts
@@ -54,6 +54,7 @@ abstract class CacheDistributor {
     } else {
       core.info(`${this.packageManager} cache is not found`);
     }
+    core.info('cache was hit');
     core.setOutput('cache-hit', Boolean(matchedKey));
   }
 }