Commit 35f4702f authored by jongwooo's avatar jongwooo
Browse files

refactor: Use early return pattern to avoid nested conditions

Signed-off-by: default avatarjongwooo <[email protected]>
parent e2d61441
Loading
Loading
Loading
Loading
+4 −5
Changes for dist/restore/index.js: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -38489,18 +38489,17 @@ function getInputAsInt(name, options) {
}
exports.getInputAsInt = getInputAsInt;
function isCacheFeatureAvailable() {
    if (!cache.isFeatureAvailable()) {
    if (cache.isFeatureAvailable()) {
        return true;
    }
    if (isGhes()) {
        logWarning(`Cache action 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.
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
        return false;
    }
        else {
    logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
        }
    return false;
}
    return true;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
+4 −5
Changes for dist/save/index.js: 4 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -38489,18 +38489,17 @@ function getInputAsInt(name, options) {
}
exports.getInputAsInt = getInputAsInt;
function isCacheFeatureAvailable() {
    if (!cache.isFeatureAvailable()) {
    if (cache.isFeatureAvailable()) {
        return true;
    }
    if (isGhes()) {
        logWarning(`Cache action 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.
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
        return false;
    }
        else {
    logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
        }
    return false;
}
    return true;
}
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
+7 −6
Changes for src/utils/actionUtils.ts: 7 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -77,19 +77,20 @@ export function getInputAsInt(
}

export function isCacheFeatureAvailable(): boolean {
    if (!cache.isFeatureAvailable()) {
    if (cache.isFeatureAvailable()) {
        return true;
    }

    if (isGhes()) {
        logWarning(
            `Cache action 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.
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/[email protected]/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`
        );
        } else {
        return false;
    }

    logWarning(
        "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
    );
        }
    return false;
}

    return true;
}