mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
fix(cli): honor no-color before rendering help and version (#4248)
Co-authored-by: shuaiyafei <16618929+shuaiyafei@users.noreply.github.com>
This commit is contained in:
1 parent
4487dd0c9b
commit
64d00f4ab2
2 files changed
+18
-7
No files matched your search
@@ -384,9 +384,20 @@ describe('CLI', () => {
|
||||
});
|
||||
|
||||
it('should disable color with --no-color', async () => {
|
||||
await cli.run(['--no-color', '--help']);
|
||||
// Color should be disabled - check output formatter state
|
||||
expect(cli['output']['colorEnabled']).toBe(false);
|
||||
const originalColorEnabled = cli['output']['colorEnabled'];
|
||||
try {
|
||||
for (const flag of ['--help', '--version', '-V']) {
|
||||
// CI starts without a TTY; explicitly enable colors so this cannot
|
||||
// pass merely because the formatter already has colors disabled.
|
||||
cli['output'].setColorEnabled(true);
|
||||
consoleOutput.length = 0;
|
||||
await cli.run(['--no-color', flag]);
|
||||
expect(cli['output']['colorEnabled']).toBe(false);
|
||||
expect(consoleOutput.join('')).not.toMatch(/\u001b\[/);
|
||||
}
|
||||
} finally {
|
||||
cli['output'].setColorEnabled(originalColorEnabled);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -108,15 +108,15 @@ export class CLI {
|
||||
const { command: commandPath, flags, positional } = parseResult;
|
||||
|
||||
// Handle global flags
|
||||
if (flags.noColor || flags.color === false) {
|
||||
this.output.setColorEnabled(false);
|
||||
}
|
||||
|
||||
if (flags.version || flags.V) {
|
||||
this.showVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags.noColor) {
|
||||
this.output.setColorEnabled(false);
|
||||
}
|
||||
|
||||
// Set verbosity level based on flags
|
||||
if (flags.quiet) {
|
||||
this.output.setVerbosity('quiet');
|
||||
|
||||
Reference in new issue
Block a user