feat: notify when a new version is available#31
Merged
Conversation
Number("") and Number(" 2") coerce successfully, letting strings like
"1..3", "1.2.-3", "1. 2.3", and "01.2.3" slip past validation and be
misread as valid semver, breaking the update notifier's core safety
guarantee that garbage never triggers a nag. Each segment must now
match /^(0|[1-9]\d*)$/ before being coerced to a number.
readNotice and cacheAgeOk left the preceding fs.exists call outside their try/catch, so Bun's exists() rejecting (e.g. EACCES/ENOTDIR on a broken HOME/XDG_CACHE_HOME) would throw past both call sites in cli.ts, which run unwrapped on the hot path. Wrap the whole cache-reading body, including fs.exists, in both functions so any failure degrades to silence per the module's never-crash contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
How it works
The update check runs as a detached background process, so it never delays the execution of the main command. The notice is displayed from a cached result, ensuring zero latency impact. The check runs at most once per 24 hours.
Per-channel commands: The notice intelligently detects how ttm was installed and suggests the right update command:
npm i -g @bumaruf/ttm-clisudo apt upgrade ttmOpt-out: Set
TTM_NO_UPDATE_CHECK=1to disable the checks entirely.Teardown contract: The notice is printed after the TUI closes, so it doesn't interfere with the interactive session.
Notes
ttm updatewithout needing to update ttm itself — this notifier only alerts you to changes in the tool's code