Skip to content

Commit

Permalink
💾 Feat(ScriptsManager): Supports executing script in alone process
Browse files Browse the repository at this point in the history
  • Loading branch information
Dynesshely committed Jul 4, 2024
1 parent d653f5d commit 594480f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Cheese/Utils/Managers/ScriptsManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
using Cheese.Options;
using Cheese.Utils.General;
using Common.BasicHelper.Core.Shell;
using Common.BasicHelper.Utils.Extensions;
using Spectre.Console;

Expand Down Expand Up @@ -90,7 +92,19 @@ public ScriptsManager Execute(ScriptsOptions options)

var script = File.ReadAllText(finalFileToExecute!);

ConsoleHelper.Instance.AccentLine("Executing ...");
ConsoleHelper.Instance.AccentLine($"Executing ...{(options.InAloneProcess ? " (Alone)" : "")}");

if (options.InAloneProcess)
{
var process = Process.Start(new ProcessStartInfo(EnvironmentHelper.GetFilePathInPaths("cheese"), $"scripts -e {options.Execute}")
{
CreateNoWindow = true,
UseShellExecute = false
});
ArgumentNullException.ThrowIfNull(process, nameof(process));
ConsoleHelper.Instance.AccentLine($"Alone process owns pid: {process.Id}");
return this;
}

var failed = false;

Expand Down

0 comments on commit 594480f

Please sign in to comment.