Skip to content

Commit

Permalink
Better solution less hacky
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelMayer committed Feb 14, 2022
1 parent e5e003c commit d002a40
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Source/Dafny/Compilers/Compiler-js.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2392,26 +2392,23 @@ bool SendToNewNodeProcess(string dafnyProgramName, string targetProgramText, str

try {
using var nodeProcess = Process.Start(psi);
nodeProcess.BeginOutputReadLine();
nodeProcess.BeginErrorReadLine();
var firstTimeError = true;
var firstTimeOutput = true;
nodeProcess.BeginOutputReadLine();

void ProcessErrorData(object sender, DataReceivedEventArgs e) {
if (firstTimeError) {
firstTimeError = false;
if (!nodeProcess.HasExited) {
Console.Error.WriteLine(e.Data);
} else {
Console.Error.WriteLine();
Console.Error.Write(e.Data);
}
Console.Error.Write(e.Data);
}

void ProcessOutputData(object sender, DataReceivedEventArgs e) {
if (firstTimeOutput) {
firstTimeOutput = false;
if (!nodeProcess.HasExited) {
Console.Out.WriteLine(e.Data);
} else {
Console.Out.WriteLine();
Console.Out.Write(e.Data);
}
Console.Out.Write(e.Data);
}
nodeProcess.ErrorDataReceived += ProcessErrorData;
nodeProcess.OutputDataReceived += ProcessOutputData;
Expand Down

0 comments on commit d002a40

Please sign in to comment.