mirror of
https://github.com/actions/setup-node.git
synced 2025-06-29 22:23:47 +00:00
Handle globs in cacheDependencyPath
This commit is contained in:
parent
2b97a8fb23
commit
914a8e9bcc
11 changed files with 1855 additions and 293 deletions
|
@ -2,7 +2,7 @@ import * as core from '@actions/core';
|
|||
import * as cache from '@actions/cache';
|
||||
import fs from 'fs';
|
||||
import {State} from './constants';
|
||||
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
|
||||
import {getCacheDirectoriesPaths, getPackageManagerInfo} from './cache-utils';
|
||||
|
||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||
|
@ -31,14 +31,17 @@ const cachePackages = async (packageManager: string) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const cachePath = await getCacheDirectoryPath(
|
||||
// TODO: core.getInput has a bug - it can return undefined despite its definition
|
||||
// export declare function getInput(name: string, options?: InputOptions): string;
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
||||
const cachePaths = await getCacheDirectoriesPaths(
|
||||
packageManagerInfo,
|
||||
packageManager
|
||||
cacheDependencyPath
|
||||
);
|
||||
|
||||
if (!fs.existsSync(cachePath)) {
|
||||
if (cachePaths.length === 0) {
|
||||
throw new Error(
|
||||
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`
|
||||
`Cache folder paths are not retrieved for ${packageManager} with cache-dependency-path = ${cacheDependencyPath}`
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -49,7 +52,7 @@ const cachePackages = async (packageManager: string) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const cacheId = await cache.saveCache([cachePath], primaryKey);
|
||||
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||
if (cacheId == -1) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue