From d6961464965e4375f6bd23a3f12ea3d9d27b27a9 Mon Sep 17 00:00:00 2001
From: aparnajyothi-y <147696841+aparnajyothi-y@users.noreply.github.com>
Date: Tue, 12 Dec 2023 18:39:15 +0530
Subject: [PATCH] fix for cache

---
 src/cache-save.ts | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/cache-save.ts b/src/cache-save.ts
index 4499e999..2522127a 100644
--- a/src/cache-save.ts
+++ b/src/cache-save.ts
@@ -12,10 +12,20 @@ process.on('uncaughtException', e => {
   core.info(`${warningPrefix}${e.message}`);
 });
 
-export async function run() {
+// Added early exit to resolve issue with slow post action step:
+export async function run(earlyExit?: boolean) {
   try {
     const cacheLock = core.getState(State.CachePackageManager);
-    await cachePackages(cacheLock);
+
+    if (cacheLock) {
+      await cachePackages(cacheLock);
+
+      if (earlyExit) {
+        process.exit(0);
+      }
+    } else {
+      core.debug(`Caching for '${cacheLock}' is not supported`);
+    }
   } catch (error) {
     core.setFailed((error as Error).message);
   }
@@ -58,4 +68,4 @@ const cachePackages = async (packageManager: string) => {
   core.info(`Cache saved with the key: ${primaryKey}`);
 };
 
-run();
+run(true);