From 570bd1fa2be72ef25f3c09fe83432e5126a71794 Mon Sep 17 00:00:00 2001 From: Joakim Carlstein Date: Wed, 22 Nov 2023 14:35:07 +0100 Subject: [PATCH] feat(cli): make the default reporter print the full command output when done In interactive mode the output is normally clipped to the number of lines that the current terminal window can show without scrolling so to remedy that the full command output is now printed to the console when done --- .changeset/cool-badgers-allow.md | 5 +++++ packages/cli/src/reporters/default.ts | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .changeset/cool-badgers-allow.md diff --git a/.changeset/cool-badgers-allow.md b/.changeset/cool-badgers-allow.md new file mode 100644 index 0000000..ac42a12 --- /dev/null +++ b/.changeset/cool-badgers-allow.md @@ -0,0 +1,5 @@ +--- +'@emigrate/cli': patch +--- + +The default reporter now prints the full command output once a command is done (in interactive mode) so that the full output is visible no matter the size of the terminal window. diff --git a/packages/cli/src/reporters/default.ts b/packages/cli/src/reporters/default.ts index cd69c58..f92511c 100644 --- a/packages/cli/src/reporters/default.ts +++ b/packages/cli/src/reporters/default.ts @@ -295,7 +295,7 @@ class DefaultFancyReporter implements Required { } } - #render(): void { + #render(flush = false): void { const parts = [ getTitle(this.#parameters), getHeaderMessage(this.#migrations, this.#lockedMigrations), @@ -303,7 +303,17 @@ class DefaultFancyReporter implements Required { getSummary(this.#parameters.command, this.#migrations), getError(this.#error), ]; - logUpdate('\n' + parts.filter(Boolean).join('\n\n') + '\n'); + + const output = '\n' + parts.filter(Boolean).join('\n\n') + '\n'; + + if (flush) { + logUpdate.clear(); + logUpdate.done(); + console.log(output); + return; + } + + logUpdate(output); } #start(): void { @@ -319,7 +329,7 @@ class DefaultFancyReporter implements Required { this.#interval = undefined; } - this.#render(); + this.#render(true); } }