MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getBestAvailableUpdate

Function getBestAvailableUpdate

packages/cli/src/ui/utils/updateCheck.ts:23–40  ·  view source on GitHub ↗

* From a nightly and stable update, determines which is the "best" one to offer. * The rule is to always prefer nightly if the base versions are the same.

(
  nightly?: UpdateInfo,
  stable?: UpdateInfo,
)

Source from the content-addressed store, hash-verified

21 * The rule is to always prefer nightly if the base versions are the same.
22 */
23function getBestAvailableUpdate(
24 nightly?: UpdateInfo,
25 stable?: UpdateInfo,
26): UpdateInfo | null {
27 if (!nightly) return stable || null;
28 if (!stable) return nightly || null;
29
30 const nightlyVer = nightly.latest;
31 const stableVer = stable.latest;
32
33 if (
34 semver.coerce(stableVer)?.version === semver.coerce(nightlyVer)?.version
35 ) {
36 return nightly;
37 }
38
39 return semver.gt(stableVer, nightlyVer) ? stable : nightly;
40}
41
42export async function checkForUpdates(): Promise<UpdateObject | null> {
43 try {

Callers 1

checkForUpdatesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected