(deps: UpdateCheckDeps = {})
| 207 | * still returns immediately from the stale cache. |
| 208 | */ |
| 209 | export function getUpdateNotice(deps: UpdateCheckDeps = {}): string | null { |
| 210 | const d = resolveDeps(deps); |
| 211 | if (updateCheckDisabled(d.env)) return null; |
| 212 | |
| 213 | const useMemo = deps.dir === undefined && deps.now === undefined; |
| 214 | const nowMs = d.now(); |
| 215 | if (useMemo && noticeMemo && nowMs - noticeMemo.at < NOTICE_MEMO_TTL_MS) { |
| 216 | return noticeMemo.value; |
| 217 | } |
| 218 | |
| 219 | const cached = readUpdateCheckCache(d.dir); |
| 220 | if (!cacheIsFresh(cached, nowMs)) { |
| 221 | void refreshUpdateCheck(deps).catch(() => { /* fail silent */ }); |
| 222 | } |
| 223 | const value = noticeFrom(cached, d); |
| 224 | if (useMemo) noticeMemo = { at: nowMs, value }; |
| 225 | return value; |
| 226 | } |
| 227 | |
| 228 | /** Test hook: clear the per-process memo. */ |
| 229 | export function resetUpdateNoticeMemo(): void { |
no test coverage detected