Skip to content

Commit a0e6efb

Browse files
authored
Merge pull request #1104 from heygen-com/05-28-fix_cli_update_notice_double_print
fix(cli): print the update-available notice once, not on every event-loop drain
2 parents 0c0ccce + 7f75591 commit a0e6efb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/cli/src/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ if (!isHelp && !hasJsonFlag && command !== "upgrade") {
193193
const commandStart = Date.now();
194194
let commandFailed = false;
195195

196-
// Async flush for normal exit (beforeExit fires when the event loop drains)
197-
process.on("beforeExit", () => {
196+
// Async flush for normal exit. `beforeExit` re-fires every time the
197+
// event loop drains, and the async `_flush()` itself schedules new
198+
// work — so a plain `on` listener would print the update notice (and
199+
// re-flush) once per drain (the user-reported double-print). `once`
200+
// detaches after first invocation, which is what we want for both.
201+
process.once("beforeExit", () => {
198202
_flush?.().catch(() => {});
199203
if (!hasJsonFlag) _printUpdateNotice?.();
200204
});

0 commit comments

Comments
 (0)