( currentVersion: string, options?: ResolveDistTagsOptions, )
| 265 | * Best-effort: an unreachable registry yields `updateAvailable: false`. |
| 266 | */ |
| 267 | export const checkForUpdate = async ( |
| 268 | currentVersion: string, |
| 269 | options?: ResolveDistTagsOptions, |
| 270 | ): Promise<UpdateStatus> => { |
| 271 | const channel = resolveUpdateChannel(currentVersion); |
| 272 | const command = `npm i -g ${EXECUTOR_PACKAGE_NAME}@${channel}`; |
| 273 | |
| 274 | // No dist-tag can legitimately be compared against this version (unstamped |
| 275 | // dev build, or a prerelease channel that never gets published) — do not |
| 276 | // even hit the registry, since the answer is already known. |
| 277 | const comparisonChannel = resolveComparisonChannel(currentVersion); |
| 278 | if (comparisonChannel === null) { |
| 279 | return { updateAvailable: false, currentVersion, latestVersion: null, channel, command }; |
| 280 | } |
| 281 | |
| 282 | const tags = await resolveDistTags(options); |
| 283 | const latestVersion = tags[comparisonChannel] ?? null; |
| 284 | const updateAvailable = isUpdateAvailable(currentVersion, latestVersion); |
| 285 | return { updateAvailable, currentVersion, latestVersion, channel, command }; |
| 286 | }; |
no test coverage detected