mirror of
https://github.com/actions/setup-python.git
synced 2025-07-26 08:58:21 +02:00
refactored code
This commit is contained in:
parent
e6ed85bb3a
commit
3dff46276e
4 changed files with 35 additions and 26 deletions
17
src/utils.ts
17
src/utils.ts
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue