refactor: Use early return pattern

Signed-off-by: jongwooo <jongwooo.han@gmail.com>
This commit is contained in:
jongwooo 2022-12-12 21:09:02 +09:00
parent c3ac5dd0ed
commit 32b1479849
3 changed files with 24 additions and 29 deletions

16
dist/cleanup/index.js vendored
View File

@ -68706,16 +68706,14 @@ function isGhes() {
}
exports.isGhes = isGhes;
function isCacheFeatureAvailable() {
if (!cache.isFeatureAvailable()) {
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;
if (cache.isFeatureAvailable()) {
return true;
}
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.');
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;

16
dist/setup/index.js vendored
View File

@ -105399,16 +105399,14 @@ function isGhes() {
}
exports.isGhes = isGhes;
function isCacheFeatureAvailable() {
if (!cache.isFeatureAvailable()) {
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;
if (cache.isFeatureAvailable()) {
return true;
}
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.');
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;

View File

@ -85,17 +85,16 @@ export function isGhes(): boolean {
}
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 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;
if (cache.isFeatureAvailable()) {
return true;
}
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.'
);
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}