Skip to content

Commit

Permalink
fix windows diff tool detection
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jul 10, 2020
1 parent 28b70e8 commit 1e196e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/DiffEngine/Process/ProcessCleanup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ public static void Refresh()
public static void Kill(string command)
{
Guard.AgainstNullOrEmpty(command, nameof(command));
var trimmedCommand = command.Replace("\"", "");
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
command = TrimCommand(command);
}
var matchingCommands = Commands
.Where(x => x.Command == trimmedCommand).ToList();
.Where(x => x.Command == command).ToList();
Logging.Write($"Kill: {command}. Matching count: {matchingCommands.Count}");
if (matchingCommands.Count == 0)
{
Expand All @@ -63,9 +66,19 @@ public static void Kill(string command)
}
}

static string TrimCommand(string command)
{
return command.Replace("\"", "");
}

public static bool IsRunning(string command)
{
Guard.AgainstNullOrEmpty(command, nameof(command));
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return commands.Any(x => x.Command == command);
}
command = TrimCommand(command);
return commands.Any(x => x.Command == command);
}

Expand Down
2 changes: 1 addition & 1 deletion src/DiffEngine/Process/WindowsProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ from Win32_Process
var command = (string) process["CommandLine"];
var id = (int) Convert.ChangeType(process["ProcessId"], typeof(int));
process.Dispose();
yield return new ProcessCommand(command.Replace("\"", ""), id);
yield return new ProcessCommand(command, id);
}
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649</NoWarn>
<Version>3.4.0</Version>
<Version>3.4.1</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Json, Testing, Verify, Snapshot, Approvals</PackageTags>
<Description>Enables simple verification of complex models and documents.</Description>
Expand Down

0 comments on commit 1e196e5

Please sign in to comment.