mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(cli-core): suppress transient progress in quiet and redirected output
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
2 files changed
+17
-1
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { OutputFormatter } from '../v3/@claude-flow/cli-core/src/output.ts';
|
||||
function capture(run) { const original = process.stdout.write; let output = ''; process.stdout.write = function(text) { output += text; return true; }; try { run(); return output; } finally { process.stdout.write = original; } }
|
||||
test('progress redraws stay out of redirected output', () => {
|
||||
const f = new OutputFormatter({ color: false }); f.supportsInteractiveOutput = () => false; const p = f.createProgress({ total: 2, showETA: false }); assert.equal(capture(() => { p.update(1); p.finish(); }), '');
|
||||
});
|
||||
test('quiet mode suppresses transient progress even on a terminal', () => {
|
||||
const f = new OutputFormatter({ color: false, verbosity: 'quiet' }); f.supportsInteractiveOutput = () => true; const p = f.createProgress({ total: 2, showETA: false }); assert.equal(capture(() => { p.update(1); p.finish(); }), '');
|
||||
});
|
||||
test('interactive progress remains visible', () => {
|
||||
const f = new OutputFormatter({ color: false }); f.supportsInteractiveOutput = () => true; const p = f.createProgress({ total: 2, width: 4, showETA: false }); assert.match(capture(() => p.update(1)), /\[##--\] 50.0%/);
|
||||
});
|
||||
@@ -529,6 +529,7 @@ export class Progress {
|
||||
}
|
||||
|
||||
render(): void {
|
||||
if (!this.formatter.supportsInteractiveOutput() || this.formatter.isQuiet()) return;
|
||||
const bar = this.formatter.progressBar(this.current, this.total, this.width);
|
||||
|
||||
let output = bar;
|
||||
@@ -556,7 +557,9 @@ export class Progress {
|
||||
finish(): void {
|
||||
this.current = this.total;
|
||||
this.render();
|
||||
process.stdout.write('\n');
|
||||
if (this.formatter.supportsInteractiveOutput() && !this.formatter.isQuiet()) {
|
||||
process.stdout.write('\n');
|
||||
}
|
||||
}
|
||||
|
||||
private formatTime(ms: number): string {
|
||||
|
||||
Reference in new issue
Block a user