Index: sdk/lib/_internal/pub/lib/src/utils.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart |
index 0c28a43e68ffb37854bf43c091874bd846f32d3e..30a67b0bce513cb0591a54e3b27976d95ead34cb 100644 |
--- a/sdk/lib/_internal/pub/lib/src/utils.dart |
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart |
@@ -17,6 +17,7 @@ import "package:crypto/crypto.dart"; |
import "package:http/http.dart" as http; |
import 'package:path/path.dart' as path; |
import "package:stack_trace/stack_trace.dart"; |
+import "package:yaml/yaml.dart"; |
import '../../asset/dart/serialize.dart'; |
@@ -682,19 +683,21 @@ String libraryPath(String libraryName) { |
return path.fromUri(lib.uri); |
} |
+/// Whether "special" strings such as Unicode characters or color escapes are |
+/// safe to use. |
+/// |
+/// On Windows or when not printing to a terminal, only printable ASCII |
+/// characters should be used. |
+bool get canUseSpecialChars => !runningAsTest && |
+ Platform.operatingSystem != 'windows' && |
+ stdioType(stdout) == StdioType.TERMINAL; |
+ |
/// Gets a "special" string (ANSI escape or Unicode). |
/// |
/// On Windows or when not printing to a terminal, returns something else since |
/// those aren't supported. |
-String getSpecial(String color, [String onWindows = '']) { |
- // No ANSI escapes on windows or when running tests. |
- if (runningAsTest || Platform.operatingSystem == 'windows' || |
- stdioType(stdout) != StdioType.TERMINAL) { |
- return onWindows; |
- } else { |
- return color; |
- } |
-} |
+String getSpecial(String special, [String onWindows = '']) => |
+ canUseSpecialChars ? special : onWindows; |
/// Prepends each line in [text] with [prefix]. |
/// |
@@ -894,5 +897,6 @@ bool isUserFacingException(error) { |
error is ProcessException || |
error is TimeoutException || |
error is SocketException || |
- error is WebSocketException; |
+ error is WebSocketException || |
+ error is YamlException; |
} |