This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
@@ -8,25 +9,38 @@ namespace AyaNova.Util
|
||||
{
|
||||
|
||||
|
||||
public static string Run(string cmd, string arguments)
|
||||
public static string Run(string cmd, string arguments, ILogger log = null)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
try
|
||||
{
|
||||
return RunWindows(cmd, arguments);
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return RunOSX(cmd, arguments);
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return RunWindows(cmd, arguments);
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
return RunOSX(cmd, arguments);
|
||||
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
return RunLinuxBash(cmd, arguments);
|
||||
}
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
catch (Exception ex)
|
||||
{
|
||||
return RunLinuxBash(cmd, arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
if (log != null)
|
||||
{
|
||||
log.LogError(ex, $"RunProgram error running command:{cmd} {arguments}");
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user