diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index e591ef1..149726a 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -114,12 +114,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py dependencyFile ); - if (process.platform === 'linux') { - getLinuxOSReleaseInfoSpy.mockImplementation(() => - Promise.resolve('Ubuntu-20.4') - ); - } - await cacheDistributor.restoreCache(); if (process.platform === 'linux') { diff --git a/dist/setup/index.js b/dist/setup/index.js index e5fe26e..5c3ab6d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -65484,17 +65484,10 @@ function isCacheFeatureAvailable() { exports.isCacheFeatureAvailable = isCacheFeatureAvailable; function getLinuxOSReleaseInfo() { return __awaiter(this, void 0, void 0, function* () { - const { stdout, stderr, exitCode } = yield exec.getExecOutput('lsb_release', ['-a'], { + const { stdout, stderr, exitCode } = yield exec.getExecOutput('lsb_release', ['-i -r -s'], { silent: true }); - let osVersion = ''; - let osRelease = ''; - stdout.split('\n').forEach(elem => { - if (elem.includes('Distributor')) - osVersion = elem.split(':')[1].trim(); - if (elem.includes('Release')) - osRelease = elem.split(':')[1].trim(); - }); + const [osRelease, osVersion] = stdout.trim().split('\n'); core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`); return `${osVersion}-${osRelease}`; }); diff --git a/src/utils.ts b/src/utils.ts index 085774e..e5374e9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -124,19 +124,13 @@ export function isCacheFeatureAvailable(): boolean { export async function getLinuxOSReleaseInfo() { const {stdout, stderr, exitCode} = await exec.getExecOutput( 'lsb_release', - ['-a'], + ['-i -r -s'], { silent: true } ); - let osVersion = ''; - let osRelease = ''; - - stdout.split('\n').forEach(elem => { - if (elem.includes('Distributor')) osVersion = elem.split(':')[1].trim(); - if (elem.includes('Release')) osRelease = elem.split(':')[1].trim(); - }); + const [osRelease, osVersion] = stdout.trim().split('\n'); core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`);