chore: simplify Playwright CLI (#2451)
This commit is contained in:
Родитель
2812fe3b5b
Коммит
84432a305c
|
@ -24,8 +24,6 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Microsoft.Playwright.Helpers;
|
||||
|
||||
namespace Microsoft.Playwright;
|
||||
|
@ -54,12 +52,6 @@ public class Program
|
|||
var playwrightStartInfo = new ProcessStartInfo(pwPath, allArgs)
|
||||
{
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
RedirectStandardOutput = true,
|
||||
StandardOutputEncoding = Encoding.UTF8,
|
||||
StandardErrorEncoding = Encoding.UTF8,
|
||||
};
|
||||
foreach (var pair in Driver.GetEnvironmentVariables())
|
||||
{
|
||||
|
@ -71,41 +63,9 @@ public class Program
|
|||
StartInfo = playwrightStartInfo,
|
||||
};
|
||||
|
||||
using var outputWaitHandle = new AutoResetEvent(false);
|
||||
using var errorWaitHandle = new AutoResetEvent(false);
|
||||
|
||||
pwProcess.OutputDataReceived += (_, e) =>
|
||||
{
|
||||
if (e.Data == null)
|
||||
{
|
||||
outputWaitHandle.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(e.Data);
|
||||
}
|
||||
};
|
||||
|
||||
pwProcess.ErrorDataReceived += (_, e) =>
|
||||
{
|
||||
if (e.Data == null)
|
||||
{
|
||||
errorWaitHandle.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine(e.Data);
|
||||
}
|
||||
};
|
||||
|
||||
pwProcess.Start();
|
||||
|
||||
pwProcess.BeginOutputReadLine();
|
||||
pwProcess.BeginErrorReadLine();
|
||||
|
||||
pwProcess.WaitForExit();
|
||||
outputWaitHandle.WaitOne(5000);
|
||||
errorWaitHandle.WaitOne(5000);
|
||||
return pwProcess.ExitCode;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче