export function ifVersionGte()

in src/common/utils/if_version_gte.ts [16:35]


export function ifVersionGte<T>(
  current: string | undefined,
  minimumRequiredVersion: string,
  then: () => T,
  otherwise: () => T,
): T {
  if (!valid(minimumRequiredVersion)) {
    throw new Error(`minimumRequiredVersion argument ${minimumRequiredVersion} isn't valid`);
  }

  const parsedCurrent = coerce(current);
  if (!parsedCurrent) {
    log.warn(
      `Could not parse version from "${current}", running logic for the latest GitLab version`,
    );
    return then();
  }
  if (gte(parsedCurrent, minimumRequiredVersion)) return then();
  return otherwise();
}