Skip to content

Commit d099cad

Browse files
committed
try and remove console colors from all output
1 parent 34b7879 commit d099cad

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

generator/CSharpReference.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ static string[] GetCommandsFromHelp(string stdout)
327327
.Where(l => !l.StartsWith(" "))
328328
.Select(l => l.Trim())
329329
.Select(l => l.Substring(0, l.IndexOf(" ")))
330-
.Select(l => Regex.Replace(l, @"[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]", ""))
331330
.ToArray();
332331

333332
//Console.WriteLine("Commands: ");
@@ -351,7 +350,8 @@ static async Task<string> RunCaptureStdOut(string exePath, string[] args)
351350

352351
Console.WriteLine($"Running: {exePath} {string.Join(" ", args)}");
353352

354-
return await RunCaptureStdOut(psi);
353+
string output = await RunCaptureStdOut(psi);
354+
return Util.RemoveConsoleColors(output);
355355
}
356356

357357
static async Task<string> RunCaptureStdOut(ProcessStartInfo psi)

generator/Util.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
using System.Net;
44
using System.Runtime.InteropServices;
55
using System.Runtime.Versioning;
6+
using System.Text.RegularExpressions;
67
using NuGet.Packaging;
78

89
namespace DocGenerator;
910

1011
internal class Util
1112
{
13+
public static string RemoveConsoleColors(string input)
14+
{
15+
return Regex.Replace(input, @"[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]", "");
16+
}
17+
1218
public static async Task StartShellProcess(string path, string[] arguments, string workDir)
1319
{
1420
var psi = new ProcessStartInfo() {

0 commit comments

Comments
 (0)