Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1447)

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 351703004: Improve pub's pubspec error messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/pubspec.dart ('k') | sdk/lib/_internal/pub/test/get/git/dependency_name_match_pubspec_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698