mirror of
https://github.com/flutter/packages.git
synced 2025-06-18 21:19:48 +08:00
[tool] Conditionalize color on stdout
(#4436)
Refactors colorization to a centralized utility file, and makes it all conditional on `stdout` having ANSI escape support. This makes the output more readable on LUCI, which unlike the Cirrus log display doesn't handle ANSI. Fixes https://github.com/flutter/flutter/issues/89392
This commit is contained in:
@ -9,6 +9,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_plugin_tools/src/common/core.dart';
|
||||
import 'package:flutter_plugin_tools/src/common/output_utils.dart';
|
||||
import 'package:flutter_plugin_tools/src/common/package_looping_command.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:test/test.dart';
|
||||
@ -82,6 +83,8 @@ void main() {
|
||||
late Directory thirdPartyPackagesDir;
|
||||
|
||||
setUp(() {
|
||||
// Correct color handling is part of the behavior being tested here.
|
||||
useColorForOutput = true;
|
||||
fileSystem = MemoryFileSystem();
|
||||
mockPlatform = MockPlatform();
|
||||
packagesDir = createPackagesDirectory(fileSystem: fileSystem);
|
||||
@ -90,6 +93,11 @@ void main() {
|
||||
.childDirectory('packages');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
// Restore the default behavior.
|
||||
useColorForOutput = io.stdout.supportsAnsiEscapes;
|
||||
});
|
||||
|
||||
/// Creates a TestPackageLoopingCommand instance that uses [gitDiffResponse]
|
||||
/// for git diffs, and logs output to [printOutput].
|
||||
TestPackageLoopingCommand createTestCommand({
|
||||
|
Reference in New Issue
Block a user