This commit is contained in:
Sukka 2025-09-10 17:31:10 +00:00 committed by GitHub
commit a7c414238e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,12 +67,17 @@ export async function run() {
auth.configAuthentication(registryUrl, alwaysAuth); auth.configAuthentication(registryUrl, alwaysAuth);
} }
const resolvedPackageManager = getNameFromPackageManagerField();
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');
if (cache && isCacheFeatureAvailable()) { if (isCacheFeatureAvailable()) {
// we only determine the package manager type if we can cache in the first place
if (cache) {
// in previous version of setup-node, user can explicitly specify what package manager they are using, we prefer that
core.saveState(State.CachePackageManager, cache); core.saveState(State.CachePackageManager, cache);
await restoreCache(cache, cacheDependencyPath); await restoreCache(cache, cacheDependencyPath);
} else if (resolvedPackageManager && packagemanagercache) { } else if (packagemanagercache) {
// only if user hasn't specify the "cache" (introduced in the previous version) we read the "package-manager-cache" field
const resolvedPackageManager = getNameFromPackageManagerField(); // only then we look for "package.json" for package manager
if (resolvedPackageManager) {
core.info( core.info(
"Detected package manager from package.json's packageManager field: " + "Detected package manager from package.json's packageManager field: " +
resolvedPackageManager + resolvedPackageManager +
@ -81,6 +86,8 @@ export async function run() {
core.saveState(State.CachePackageManager, resolvedPackageManager); core.saveState(State.CachePackageManager, resolvedPackageManager);
await restoreCache(resolvedPackageManager, cacheDependencyPath); await restoreCache(resolvedPackageManager, cacheDependencyPath);
} }
}
}
const matchersPath = path.join(__dirname, '../..', '.github'); const matchersPath = path.join(__dirname, '../..', '.github');
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`); core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);