[Regression] Re-enable ANSI color support on Windows (#9232)
Also adds a test to make sure we don't break it again.
This commit is contained in:
parent
03f5793cda
commit
a559b8df5c
@ -11,7 +11,7 @@ dependencies:
|
||||
args: ^0.13.4
|
||||
meta: ^1.0.4
|
||||
path: ^1.4.0
|
||||
process: 2.0.1
|
||||
process: 2.0.3
|
||||
stack_trace: ^1.4.0
|
||||
vm_service_client: '0.2.2+4'
|
||||
|
||||
|
@ -248,15 +248,6 @@ enum _LogType {
|
||||
}
|
||||
|
||||
class AnsiTerminal {
|
||||
AnsiTerminal() {
|
||||
if (platform.isWindows) {
|
||||
supportsColor = platform.ansiSupported;
|
||||
} else {
|
||||
final String term = platform.environment['TERM'];
|
||||
supportsColor = (term != null && term != 'dumb');
|
||||
}
|
||||
}
|
||||
|
||||
static const String _bold = '\u001B[1m';
|
||||
static const String _reset = '\u001B[0m';
|
||||
static const String _clear = '\u001B[2J\u001B[H';
|
||||
@ -275,7 +266,7 @@ class AnsiTerminal {
|
||||
_INVALID_HANDLE,
|
||||
];
|
||||
|
||||
bool supportsColor;
|
||||
bool supportsColor = platform.stdoutSupportsAnsi;
|
||||
|
||||
String bolden(String message) {
|
||||
if (!supportsColor)
|
||||
|
@ -22,8 +22,8 @@ dependencies:
|
||||
meta: ^1.0.4
|
||||
mustache: ^0.2.5
|
||||
package_config: '>=0.1.5 <2.0.0'
|
||||
platform: 1.1.1
|
||||
process: 2.0.1
|
||||
platform: 2.0.0
|
||||
process: 2.0.3
|
||||
quiver: ^0.24.0
|
||||
stack_trace: ^1.4.0
|
||||
usage: ^3.0.1
|
||||
|
21
packages/flutter_tools/test/src/base/logger_test.dart
Normal file
21
packages/flutter_tools/test/src/base/logger_test.dart
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('AnsiLogger', () {
|
||||
test('should support color on Windows version >= 10.0.10586', () {
|
||||
final String name = new OperatingSystemUtils().name;
|
||||
final String versionString = new RegExp(r'\d+\.\d+\.\d+').firstMatch(name).group(0);
|
||||
final Version version = new Version.parse(versionString);
|
||||
final bool shouldSupportColor = version >= new Version.parse('10.0.10586');
|
||||
|
||||
expect(new AnsiTerminal().supportsColor, shouldSupportColor);
|
||||
}, testOn: 'windows');
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user