Skip to content

Commit a00c36e

Browse files
committed
Pub shouldn't emit colored log output unless it's to a terminal.
[email protected] BUG=14195 Review URL: https://codereview.chromium.org//66303006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30167 260f80e4-7a28-3924-810f-c04153c831b5
1 parent fcb74c7 commit a00c36e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sdk/lib/_internal/pub/lib/src/utils.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,18 @@ String libraryPath(String libraryName) {
590590
return path.fromUri(lib.uri);
591591
}
592592

593-
/// Gets a "special" string (ANSI escape or Unicode). On Windows, returns
594-
/// something else since those aren't supported.
593+
/// Gets a "special" string (ANSI escape or Unicode).
594+
///
595+
/// On Windows or when not printing to a terminal, returns something else since
596+
/// those aren't supported.
595597
String getSpecial(String color, [String onWindows = '']) {
596598
// No ANSI escapes on windows or when running tests.
597-
if (runningAsTest || Platform.operatingSystem == 'windows') return onWindows;
598-
return color;
599+
if (runningAsTest || Platform.operatingSystem == 'windows' ||
600+
stdioType(stdout) != StdioType.TERMINAL) {
601+
return onWindows;
602+
} else {
603+
return color;
604+
}
599605
}
600606

601607
/// Prepends each line in [text] with [prefix]. If [firstPrefix] is passed, the

0 commit comments

Comments
 (0)