Refactor OS info retrieval to use getOSInfo and handle null cases for improved reliability

This commit is contained in:
priyagupta108 2026-06-17 15:28:43 +05:30
parent f1ee88690f
commit 5ad36cd2ac
3 changed files with 14 additions and 4 deletions

View File

@ -51256,7 +51256,10 @@ class CacheDistributor {
if (!utils_1.IS_LINUX) {
return '';
}
const osInfo = await (0, utils_1.getLinuxInfo)();
const osInfo = await (0, utils_1.getOSInfo)();
if (!osInfo) {
return '';
}
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
const normalizedName = osInfo.osName.toLowerCase();

5
dist/setup/index.js vendored
View File

@ -53838,7 +53838,10 @@ class CacheDistributor {
if (!utils_1.IS_LINUX) {
return '';
}
const osInfo = await (0, utils_1.getLinuxInfo)();
const osInfo = await (0, utils_1.getOSInfo)();
if (!osInfo) {
return '';
}
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
const normalizedName = osInfo.osName.toLowerCase();

View File

@ -1,6 +1,6 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {getLinuxInfo, IS_LINUX} from '../utils';
import {getOSInfo, IS_LINUX} from '../utils';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
export enum State {
@ -32,7 +32,11 @@ abstract class CacheDistributor {
return '';
}
const osInfo = await getLinuxInfo();
const osInfo = await getOSInfo();
if (!osInfo) {
return '';
}
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
const normalizedName = osInfo.osName.toLowerCase();