Skip to content

Commit 8d6a5a7

Browse files
Merge pull request #236 from BorisTheBrave/electronize-cli-false-positive
Reduce chance of detecting false positives when scanning subprocesses for errors.
2 parents f2e0808 + a5cee6e commit 8d6a5a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ElectronNET.CLI/ProcessHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
22
using System.Diagnostics;
33
using System.Runtime.InteropServices;
4+
using System.Text.RegularExpressions;
45

56
namespace ElectronNET.CLI
67
{
78
public class ProcessHelper
89
{
10+
private readonly static Regex ErrorRegex = new Regex(@"\berror\b", RegexOptions.IgnoreCase | RegexOptions.Compiled);
11+
912
public static int CmdExecute(string command, string workingDirectoryPath, bool output = true, bool waitForExit = true)
1013
{
1114
using (Process cmd = new Process())
@@ -44,7 +47,7 @@ public static int CmdExecute(string command, string workingDirectoryPath, bool o
4447
// 1 if something fails
4548
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
4649
{
47-
if (e.Data.ToLowerInvariant().Contains("error"))
50+
if (ErrorRegex.IsMatch(e.Data))
4851
{
4952
returnCode = 1;
5053
}
@@ -63,7 +66,7 @@ public static int CmdExecute(string command, string workingDirectoryPath, bool o
6366
// 1 if something fails
6467
if (e != null && string.IsNullOrWhiteSpace(e.Data) == false)
6568
{
66-
if (e.Data.ToLowerInvariant().Contains("error"))
69+
if (ErrorRegex.IsMatch(e.Data))
6770
{
6871
returnCode = 1;
6972
}

0 commit comments

Comments
 (0)