( pkg: string, current: string, )
| 115 | * we don't hammer the npm registry on every launch. |
| 116 | */ |
| 117 | export async function getUpdateInfo( |
| 118 | pkg: string, |
| 119 | current: string, |
| 120 | ): Promise<UpdateInfo> { |
| 121 | const cached = readCache(); |
| 122 | if (cached && Date.now() - cached.checkedAt < CACHE_TTL_MS) { |
| 123 | return makeResult(current, cached.latest); |
| 124 | } |
| 125 | const latest = await fetchLatestNpmVersion(pkg); |
| 126 | if (latest !== null) writeCache(latest); |
| 127 | return makeResult(current, latest); |
| 128 | } |
| 129 | |
| 130 | function makeResult(current: string, latest: string | null): UpdateInfo { |
| 131 | if (latest === null) { |
no test coverage detected