Skip to content

Commit

Permalink
powershell added
Browse files Browse the repository at this point in the history
  • Loading branch information
rob1997 committed Oct 15, 2024
1 parent c5d7f1c commit 83d1d49
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 30 deletions.
6 changes: 3 additions & 3 deletions Setup/Git.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ public static class Git
{
public static void Add(string path)
{
$"git add \"{path}\" -f".RunWithBash();
$"git add \"{path}\" -f".RunWithPowerShell();
}

public static void Commit(string message)
{
$"git commit -m \"{message}\"".RunWithBash();
$"git commit -m \"{message}\"".RunWithPowerShell();
}

public static void Push()
{
"git push".RunWithBash();
"git push".RunWithPowerShell();
}
}
4 changes: 0 additions & 4 deletions Setup/Release.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Setup;

public class Release
Expand All @@ -24,8 +22,6 @@ public void Run()
package.Save();

Git.Add(package.Path);

Console.WriteLine(package.Path);
}

Git.Commit($"Release {_version}");
Expand Down
1 change: 1 addition & 0 deletions Setup/Setup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Management.Automation" Version="7.4.5" />
</ItemGroup>

</Project>
28 changes: 5 additions & 23 deletions Setup/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Management.Automation;

namespace Setup;

public static class Utils
{
public static void RunWithBash( this string cmd )
public static void RunWithPowerShell(this string command)
{
cmd = cmd.Replace( "\"", "\\\"" );

Process process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = $"-c \"{cmd}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};

process.Start();

string result = process.StandardOutput.ReadToEnd();

process.WaitForExit();

foreach (string line in result.Split('\n'))
using (PowerShell powershell = PowerShell.Create())
{
Console.WriteLine(line);
var output = powershell.AddScript(@command).Invoke();
}
}
}

0 comments on commit 83d1d49

Please sign in to comment.