Skip to content

Commit

Permalink
dist/
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Jun 14, 2023
1 parent 6aacde7 commit 13ce559
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/cache-restore.ts
Expand Up @@ -37,7 +37,7 @@ export const restoreCache = async (
);
}

const primaryKey = `node-cache-${platform}-${packageManager}-v2-${fileHash}`;
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`);

core.saveState(State.CachePrimaryKey, primaryKey);
Expand Down
23 changes: 3 additions & 20 deletions src/cache-utils.ts
Expand Up @@ -110,11 +110,6 @@ export const getPackageManagerInfo = async (packageManager: string) => {
}
};

/**
* glob expanding memoized because it involves potentially very deep
* traversing through the directories tree
*/
export const memoizedCacheDependencies: Record<string, string[]> = {};
/**
* Expands (converts) the string input `cache-dependency-path` to list of directories that
* may be project roots
Expand All @@ -125,29 +120,17 @@ export const memoizedCacheDependencies: Record<string, string[]> = {};
const getProjectDirectoriesFromCacheDependencyPath = async (
cacheDependencyPath: string
): Promise<string[]> => {
let cacheDependenciesPaths: string[];

// memoize unglobbed paths to avoid traversing FS
const memoized = memoizedCacheDependencies[cacheDependencyPath];
if (memoized) {
cacheDependenciesPaths = memoized;
} else {
const globber = await glob.create(cacheDependencyPath);
cacheDependenciesPaths = await globber.glob();
memoizedCacheDependencies[cacheDependencyPath] = cacheDependenciesPaths;
}
const globber = await glob.create(cacheDependencyPath);
const cacheDependenciesPaths = await globber.glob();

const existingDirectories: string[] = cacheDependenciesPaths
.map(path.dirname)
.filter(unique())
.filter(fs.existsSync)
.filter(directory => fs.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
// result to the whole build
if (!existingDirectories.length)
throw Error(
core.warning(
'No existing directories found containing `cache-dependency-path`="${cacheDependencyPath}"'
);

Expand Down

0 comments on commit 13ce559

Please sign in to comment.