mirror of
https://github.com/actions/setup-node.git
synced 2025-07-23 15:08:24 +02:00
Handle globs in cacheDependencyPath
This commit is contained in:
parent
52e352b14a
commit
6af80f316c
11 changed files with 1714 additions and 290 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,15 @@ const cachePackages = async (packageManager: string) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const cachePath = await getCacheDirectoryPath(
|
||||
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 +50,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