(currentVersion: string)
| 51 | } |
| 52 | |
| 53 | export async function checkForUpdate(currentVersion: string): Promise<void> { |
| 54 | // Skip in CI / non-TTY environments |
| 55 | if (process.env.CI || !process.stderr.isTTY) return; |
| 56 | |
| 57 | const state = readState(); |
| 58 | const now = Date.now(); |
| 59 | |
| 60 | // Throttle: skip if checked within the last 24h |
| 61 | if (state && now - state.lastChecked < CHECK_INTERVAL_MS) { |
| 62 | if (state.latestVersion && state.latestVersion !== `v${currentVersion}`) { |
| 63 | pendingNotification = state.latestVersion; |
| 64 | } |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | const latest = await fetchLatestVersion(); |
| 69 | if (!latest) return; |
| 70 | |
| 71 | writeState({ lastChecked: now, latestVersion: latest }); |
| 72 | |
| 73 | if (latest !== `v${currentVersion}`) { |
| 74 | pendingNotification = latest; |
| 75 | } |
| 76 | } |
no test coverage detected