refactor: Use early return pattern

Signed-off-by: jongwooo <jongwooo.han@gmail.com>
This commit is contained in:
Jongwoo Han 2022-12-12 20:47:46 +09:00 committed by jongwooo
parent 2c3dd9e7e2
commit 8606abc738
2 changed files with 19 additions and 22 deletions

8
dist/setup/index.js vendored
View file

@ -67057,17 +67057,15 @@ function isGhes() {
}
exports.isGhes = isGhes;
function isCacheFeatureAvailable() {
if (!cache.isFeatureAvailable()) {
if (cache.isFeatureAvailable()) {
return true;
}
if (isGhes()) {
throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.');
}
else {
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
}
return false;
}
return true;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function logWarning(message) {
const warningPrefix = '[warning]';

View file

@ -105,23 +105,22 @@ export function isGhes(): boolean {
}
export function isCacheFeatureAvailable(): boolean {
if (!cache.isFeatureAvailable()) {
if (cache.isFeatureAvailable()) {
return true;
}
if (isGhes()) {
throw new Error(
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);
} else {
}
core.warning(
'The runner was not able to contact the cache service. Caching will be skipped'
);
}
return false;
}
return true;
}
export function logWarning(message: string): void {
const warningPrefix = '[warning]';
core.info(`${warningPrefix}${message}`);