mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-20 05:14:44 +00:00
Support caching for mono repos and repositories with complex structure
This commit is contained in:
parent
aa759c6c94
commit
9f31dbbbc4
7 changed files with 727 additions and 674 deletions
|
@ -11,7 +11,10 @@ import {
|
|||
PackageManagerInfo
|
||||
} from './cache-utils';
|
||||
|
||||
export const restoreCache = async (packageManager: string) => {
|
||||
export const restoreCache = async (
|
||||
packageManager: string,
|
||||
cacheDependencyPath?: string
|
||||
) => {
|
||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||
if (!packageManagerInfo) {
|
||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||
|
@ -22,9 +25,17 @@ export const restoreCache = async (packageManager: string) => {
|
|||
packageManagerInfo,
|
||||
packageManager
|
||||
);
|
||||
const lockFilePath = findLockFile(packageManagerInfo);
|
||||
const lockFilePath = cacheDependencyPath
|
||||
? cacheDependencyPath
|
||||
: findLockFile(packageManagerInfo);
|
||||
const fileHash = await glob.hashFiles(lockFilePath);
|
||||
|
||||
if (!fileHash) {
|
||||
throw new Error(
|
||||
'Some specified paths were not resolved, unable to cache dependencies.'
|
||||
);
|
||||
}
|
||||
|
||||
const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`;
|
||||
core.debug(`primary key is ${primaryKey}`);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue