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
|
public class AnsiConsole
|
||||||
{
|
{
|
||||||
private AnsiConsole(TextWriter writer, bool useConsoleColor)
|
private AnsiConsole(TextWriter writer)
|
||||||
{
|
{
|
||||||
Writer = writer;
|
Writer = writer;
|
||||||
|
OriginalForegroundColor = Console.ForegroundColor;
|
||||||
_useConsoleColor = useConsoleColor;
|
|
||||||
if (_useConsoleColor)
|
|
||||||
{
|
|
||||||
OriginalForegroundColor = Console.ForegroundColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _boldRecursion;
|
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; }
|
public TextWriter Writer { get; }
|
||||||
|
@ -54,12 +48,6 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
||||||
|
|
||||||
public void WriteLine(string message)
|
public void WriteLine(string message)
|
||||||
{
|
{
|
||||||
if (!_useConsoleColor)
|
|
||||||
{
|
|
||||||
Writer.WriteLine(message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var escapeScan = 0;
|
var escapeScan = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,16 +19,9 @@ namespace Microsoft.DotNet.Cli.Build.Framework
|
||||||
_console = console;
|
_console = console;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Reporter Output { get; } = Create(AnsiConsole.GetOutput);
|
public static Reporter Output { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||||
public static Reporter Error { get; } = Create(AnsiConsole.GetOutput);
|
public static Reporter Error { get; } = new Reporter(AnsiConsole.GetOutput());
|
||||||
public static Reporter Verbose { get; } = Create(AnsiConsole.GetOutput);
|
public static Reporter Verbose { get; } = new Reporter(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 void WriteLine(string message)
|
public void WriteLine(string message)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue