Update Reporter in build.
This commit is contained in:
parent
619eaa0c55
commit
b2fab6df02
2 changed files with 9 additions and 28 deletions
|
@ -8,28 +8,22 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
{
|
||||
public class AnsiConsole
|
||||
{
|
||||
private AnsiConsole(TextWriter writer, bool useConsoleColor)
|
||||
private AnsiConsole(TextWriter writer)
|
||||
{
|
||||
Writer = writer;
|
||||
|
||||
_useConsoleColor = useConsoleColor;
|
||||
if (_useConsoleColor)
|
||||
{
|
||||
OriginalForegroundColor = Console.ForegroundColor;
|
||||
}
|
||||
OriginalForegroundColor = Console.ForegroundColor;
|
||||
}
|
||||
|
||||
private int _boldRecursion;
|
||||
private bool _useConsoleColor;
|
||||
|
||||
public static AnsiConsole GetOutput(bool useConsoleColor)
|
||||
public static AnsiConsole GetOutput()
|
||||
{
|
||||
return new AnsiConsole(Console.Out, useConsoleColor);
|
||||
return new AnsiConsole(Console.Out);
|
||||
}
|
||||
|
||||
public static AnsiConsole GetError(bool useConsoleColor)
|
||||
public static AnsiConsole GetError()
|
||||
{
|
||||
return new AnsiConsole(Console.Error, useConsoleColor);
|
||||
return new AnsiConsole(Console.Error);
|
||||
}
|
||||
|
||||
public TextWriter Writer { get; }
|
||||
|
@ -54,12 +48,6 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
|
||||
public void WriteLine(string message)
|
||||
{
|
||||
if (!_useConsoleColor)
|
||||
{
|
||||
Writer.WriteLine(message);
|
||||
return;
|
||||
}
|
||||
|
||||
var escapeScan = 0;
|
||||
for (;;)
|
||||
{
|
||||
|
|
|
@ -19,16 +19,9 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
|||
_console = console;
|
||||
}
|
||||
|
||||
public static Reporter Output { get; } = Create(AnsiConsole.GetOutput);
|
||||
public static Reporter Error { get; } = Create(AnsiConsole.GetOutput);
|
||||
public static Reporter Verbose { get; } = Create(AnsiConsole.GetOutput);
|
||||
|
||||
public static Reporter Create(Func<bool, AnsiConsole> getter)
|
||||
{
|
||||
var stripColors = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ||
|
||||
string.Equals(Environment.GetEnvironmentVariable("NO_COLOR"), "1");
|
||||
return new Reporter(getter(stripColors));
|
||||
}
|
||||
public static Reporter Output { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||
public static Reporter Error { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||
public static Reporter Verbose { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||
|
||||
public void WriteLine(string message)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue