Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5eaa296

Browse files
authored
When et is not attached to a terminal, still split lines for status updates. (#52681)
For illustrative purposes: ```sh $ et build | grep '.*' ``` ... should still get line-per-line status updates, but it does not without this patch. It's hard to write tests because of global state, so I've declined to do so at the moment. Closes flutter/flutter#147903.
1 parent 233a57b commit 5eaa296

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/engine_tool/lib/src/logger.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,20 @@ class Logger {
165165
_emitLog(infoLevel, message, indent, newline, fit);
166166
}
167167

168-
/// Writes a number of spaces to stdout equal to the width of the terminal
169-
/// and emits a carriage return.
168+
/// Functionally ends and starts a new line.
169+
///
170+
/// How that is done depends on the terminal capabilities:
171+
///
172+
/// - If we are not in a terminal, just write a newline.
173+
/// - If we are in a a terminal, any spinners are temporarily paused, the
174+
/// current line is cleared, and spinners are resumed. If ANSI escapes are
175+
/// supported, the cursor is moved to the start of the line and the line is
176+
/// cleared. Otherwise, the line is cleared by writing spaces to the width
177+
/// of the terminal, then moving the cursor back to the start of the line.
170178
void clearLine() {
171179
if (!io.stdout.hasTerminal || _test) {
180+
// Just write a newline if we're not in a terminal.
181+
_ioSinkWrite(io.stdout, '\n');
172182
return;
173183
}
174184
_status?.pause();

0 commit comments

Comments
 (0)