Skip to content

Commit

Permalink
feat(cli): make the default reporter print the full command output wh…
Browse files Browse the repository at this point in the history
…en 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
  • Loading branch information
joakimbeng committed Nov 22, 2023
1 parent 8f623ef commit 570bd1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-badgers-allow.md
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 13 additions & 3 deletions packages/cli/src/reporters/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,25 @@ class DefaultFancyReporter implements Required<EmigrateReporter> {
}
}

#render(): void {
#render(flush = false): void {
const parts = [
getTitle(this.#parameters),
getHeaderMessage(this.#migrations, this.#lockedMigrations),
this.#migrations?.map((migration) => getMigrationText(migration, this.#activeMigration)).join('\n') ?? '',
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 {
Expand All @@ -319,7 +329,7 @@ class DefaultFancyReporter implements Required<EmigrateReporter> {
this.#interval = undefined;
}

this.#render();
this.#render(true);
}
}

Expand Down

0 comments on commit 570bd1f

Please sign in to comment.