diff --git a/src/cli/update-notifier.test.ts b/src/cli/update-notifier.test.ts index 7c13fdd..70d0fdd 100644 --- a/src/cli/update-notifier.test.ts +++ b/src/cli/update-notifier.test.ts @@ -71,6 +71,11 @@ describe("runUpdateNotifier", () => { await runUpdateNotifier(makeBombContainer(), "1.0.0"); }); + test("skips when argv contains self-update command", async () => { + process.argv = ["bun", "wt", "self-update"]; + await runUpdateNotifier(makeBombContainer(), "1.0.0"); + }); + test("calls checkForUpdates on normal TTY invocation", async () => { let readFileCalled = false; diff --git a/src/cli/update-notifier.ts b/src/cli/update-notifier.ts index e2cd00c..7554c58 100644 --- a/src/cli/update-notifier.ts +++ b/src/cli/update-notifier.ts @@ -8,10 +8,14 @@ import { getCacheDir } from "../shared/xdg-paths.ts"; export const UPDATE_CHECK_FILENAME = "update-check.json"; const SKIP_FLAGS = new Set(["--help", "-h", "--version", "-v"]); +// Commands for which the "update available" notice would be redundant or misleading. +// `self-update` mutates the binary mid-process; the exit-time notice captured a stale +// version in its closure and would print after a successful upgrade. +const SKIP_COMMANDS = new Set(["self-update"]); export async function runUpdateNotifier(container: Container, currentVersion: string): Promise { if (!process.stdout.isTTY) return; - if (process.argv.some((arg) => SKIP_FLAGS.has(arg))) return; + if (process.argv.some((arg) => SKIP_FLAGS.has(arg) || SKIP_COMMANDS.has(arg))) return; const cachePath = join(getCacheDir(), UPDATE_CHECK_FILENAME);