From d2b7e08b805651040ed23e4f7f3ba8d8dd6da1b3 Mon Sep 17 00:00:00 2001
From: Sergey Dolin <dsame@github.com>
Date: Fri, 2 Jun 2023 18:50:25 +0200
Subject: [PATCH] review fixes

---
 dist/cache-save/index.js | 11 +++++------
 dist/setup/index.js      | 11 +++++------
 src/cache-utils.ts       | 16 +++++-----------
 3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js
index b7b72fde..5baad46c 100644
--- a/dist/cache-save/index.js
+++ b/dist/cache-save/index.js
@@ -60522,15 +60522,14 @@ const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __
         cacheDependenciesPaths = memoized;
     }
     else {
-        cacheDependenciesPaths = (yield glob
-            .create(cacheDependencyPath)
-            .then(globber => globber.glob())) || [''];
+        const globber = yield glob.create(cacheDependencyPath);
+        cacheDependenciesPaths = (yield globber.glob()) || [''];
         exports.memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
     }
     const existingDirectories = cacheDependenciesPaths
-        .map(cacheDependencyPath => path_1.default.dirname(cacheDependencyPath))
+        .map(path_1.default.dirname)
         // uniq in order to do not traverse the same directories during the further processing
-        .filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i)
+        .filter((item, i, src) => item != null && src.indexOf(item) === i)
         .filter(directory => fs_1.default.existsSync(directory) && fs_1.default.lstatSync(directory).isDirectory());
     // if user explicitly pointed out some file, but it does not exist it is definitely
     // not he wanted, thus we should throw an error not trying to workaround with unexpected
@@ -60555,7 +60554,7 @@ const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDep
         return cacheFolderPath;
     })));
     // uniq in order to do not cache the same directories twice
-    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
+    return cacheFoldersPaths.filter((item, i, src) => src.indexOf(item) === i);
 });
 /**
  * Finds the cache directories configured for the repo ignoring cache-dependency-path
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 39a3cef8..6b2f7404 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -71304,15 +71304,14 @@ const getProjectDirectoriesFromCacheDependencyPath = (cacheDependencyPath) => __
         cacheDependenciesPaths = memoized;
     }
     else {
-        cacheDependenciesPaths = (yield glob
-            .create(cacheDependencyPath)
-            .then(globber => globber.glob())) || [''];
+        const globber = yield glob.create(cacheDependencyPath);
+        cacheDependenciesPaths = (yield globber.glob()) || [''];
         exports.memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
     }
     const existingDirectories = cacheDependenciesPaths
-        .map(cacheDependencyPath => path_1.default.dirname(cacheDependencyPath))
+        .map(path_1.default.dirname)
         // uniq in order to do not traverse the same directories during the further processing
-        .filter((cachePath, i, result) => cachePath != null && result.indexOf(cachePath) === i)
+        .filter((item, i, src) => item != null && src.indexOf(item) === i)
         .filter(directory => fs_1.default.existsSync(directory) && fs_1.default.lstatSync(directory).isDirectory());
     // if user explicitly pointed out some file, but it does not exist it is definitely
     // not he wanted, thus we should throw an error not trying to workaround with unexpected
@@ -71337,7 +71336,7 @@ const getCacheDirectoriesFromCacheDependencyPath = (packageManagerInfo, cacheDep
         return cacheFolderPath;
     })));
     // uniq in order to do not cache the same directories twice
-    return cacheFoldersPaths.filter((cachePath, i, result) => result.indexOf(cachePath) === i);
+    return cacheFoldersPaths.filter((item, i, src) => src.indexOf(item) === i);
 });
 /**
  * Finds the cache directories configured for the repo ignoring cache-dependency-path
diff --git a/src/cache-utils.ts b/src/cache-utils.ts
index 2d244b65..5884c000 100644
--- a/src/cache-utils.ts
+++ b/src/cache-utils.ts
@@ -131,19 +131,15 @@ const getProjectDirectoriesFromCacheDependencyPath = async (
   if (memoized) {
     cacheDependenciesPaths = memoized;
   } else {
-    cacheDependenciesPaths = (await glob
-      .create(cacheDependencyPath)
-      .then(globber => globber.glob())) || [''];
+    const globber = await glob.create(cacheDependencyPath);
+    cacheDependenciesPaths = (await globber.glob()) || [''];
     memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
   }
 
   const existingDirectories: string[] = cacheDependenciesPaths
-    .map(cacheDependencyPath => path.dirname(cacheDependencyPath))
+    .map(path.dirname)
     // uniq in order to do not traverse the same directories during the further processing
-    .filter(
-      (cachePath, i, result) =>
-        cachePath != null && result.indexOf(cachePath) === i
-    )
+    .filter((item, i, src) => item != null && src.indexOf(item) === i)
     .filter(
       directory =>
         fs.existsSync(directory) && fs.lstatSync(directory).isDirectory()
@@ -187,9 +183,7 @@ const getCacheDirectoriesFromCacheDependencyPath = async (
     )
   );
   // uniq in order to do not cache the same directories twice
-  return cacheFoldersPaths.filter(
-    (cachePath, i, result) => result.indexOf(cachePath) === i
-  );
+  return cacheFoldersPaths.filter((item, i, src) => src.indexOf(item) === i);
 };
 
 /**