Skip to content

Commit

Permalink
refactor project dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed May 19, 2023
1 parent 6f596e7 commit 8e8ef76
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,11 @@ export function isCacheFeatureAvailable(): boolean {
}

// a hack for further possible compatibility issues and a syntax sugar
const getYarn3ProjectDirectoryPath = () =>
getCacheDirectoryPath(supportedPackageManagers.yarn2, 'yarn');
const getYarn3ProjectDirectoryPaths = () =>
getCacheDirectoriesPaths(
supportedPackageManagers.yarn,
core.getInput('cache-dependency-path')
);

// see https://yarnpkg.com/features/offline-cache
let isYarn3OfflineCacheMemoized: boolean | null = null;
Expand All @@ -301,10 +304,11 @@ export const isYarn3OfflineCache = async (

isYarn3OfflineCacheMemoized = false;

if (packageManagerInfo !== supportedPackageManagers.yarn2)
return isYarn3OfflineCacheMemoized;
if (packageManagerInfo.name !== 'yarn') return isYarn3OfflineCacheMemoized;

const cacheDependencyPath = core.getInput('cache-dependency-path');

const yarnDir = await getYarn3ProjectDirectoryPath();
const yarnDirs = await getYarn3ProjectDirectoryPath();

const workDir = yarnDir || process.env.GITHUB_WORKSPACE!;

Expand Down

0 comments on commit 8e8ef76

Please sign in to comment.