refactored code

This commit is contained in:
Shubham Tiwari 2022-03-29 15:03:16 +05:30
parent e6ed85bb3a
commit 3dff46276e
4 changed files with 35 additions and 26 deletions

View file

@ -1,3 +1,4 @@
import * as cache from '@actions/cache';
import fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
@ -99,3 +100,19 @@ export function isGhes(): boolean {
);
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
export function isCacheFeatureAvailable(): boolean {
if (!cache.isFeatureAvailable()) {
if (isGhes()) {
throw new Error(
'Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
);
} else {
throw new Error(
'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
);
}
}
return true;
}