Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cli/update-notifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/cli/update-notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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);

Expand Down