Skip to content

Commit 119b0fe

Browse files
committed
feature: log output of custom action if Wait for action exit enabled (#1334)
Signed-off-by: leo <[email protected]>
1 parent 1dfb629 commit 119b0fe

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Commands/ExecuteCustomAction.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void Run(string repo, string file, string args)
2727
}
2828
}
2929

30-
public static void RunAndWait(string repo, string file, string args, Action<string> outputHandler)
30+
public static void RunAndWait(string repo, string file, string args, Models.ICommandLog log)
3131
{
3232
var start = new ProcessStartInfo();
3333
start.FileName = file;
@@ -40,20 +40,22 @@ public static void RunAndWait(string repo, string file, string args, Action<stri
4040
start.StandardErrorEncoding = Encoding.UTF8;
4141
start.WorkingDirectory = repo;
4242

43+
log?.AppendLine($"$ {file} {args}\n");
44+
4345
var proc = new Process() { StartInfo = start };
4446
var builder = new StringBuilder();
4547

4648
proc.OutputDataReceived += (_, e) =>
4749
{
4850
if (e.Data != null)
49-
outputHandler?.Invoke(e.Data);
51+
log?.AppendLine(e.Data);
5052
};
5153

5254
proc.ErrorDataReceived += (_, e) =>
5355
{
5456
if (e.Data != null)
5557
{
56-
outputHandler?.Invoke(e.Data);
58+
log?.AppendLine(e.Data);
5759
builder.AppendLine(e.Data);
5860
}
5961
};

src/ViewModels/ExecuteCustomAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public override Task<bool> Sure()
3636
_repo.SetWatcherEnabled(false);
3737
ProgressDescription = "Run custom action ...";
3838

39+
var log = _repo.CreateLog(CustomAction.Name);
40+
3941
return Task.Run(() =>
4042
{
4143
if (CustomAction.WaitForExit)
42-
Commands.ExecuteCustomAction.RunAndWait(_repo.FullPath, CustomAction.Executable, _args, output => CallUIThread(() => ProgressDescription = output));
44+
Commands.ExecuteCustomAction.RunAndWait(_repo.FullPath, CustomAction.Executable, _args, log);
4345
else
4446
Commands.ExecuteCustomAction.Run(_repo.FullPath, CustomAction.Executable, _args);
4547

48+
log.Complete();
4649
CallUIThread(() => _repo.SetWatcherEnabled(true));
4750
return true;
4851
});

0 commit comments

Comments
 (0)