Skip to content

Commit

Permalink
Fix lightweight tool API to expose exitHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed May 15, 2023
1 parent 832a777 commit a1344e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions source/Nuke.Tooling/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ public delegate IReadOnlyCollection<Output> Tool(
#if NET6_0_OR_GREATER
ref ArgumentStringHandler arguments,
#else
string arguments = null,
string arguments = null,
#endif
string workingDirectory = null,
IReadOnlyDictionary<string, string> environmentVariables = null,
int? timeout = null,
bool? logOutput = null,
bool? logInvocation = null,
Action<OutputType, string> customLogger = null,
Action<OutputType, string> logger = null,
Action<IProcess> exitHandler = null,
Func<string, string> outputFilter = null);
3 changes: 2 additions & 1 deletion source/Nuke.Tooling/ToolExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public IReadOnlyCollection<Output> Execute(
bool? logOutput = null,
bool? logInvocation = null,
Action<OutputType, string> customLogger = null,
Action<IProcess> exitHandler = null,
Func<string, string> outputFilter = null)
{
var process = ProcessTasks.StartProcess(
Expand All @@ -45,7 +46,7 @@ public IReadOnlyCollection<Output> Execute(
logInvocation,
customLogger,
outputFilter);
process.AssertZeroExitCode();
(exitHandler ?? (p => ProcessTasks.DefaultExitHandler(toolSettings: null, p))).Invoke(process.AssertWaitForExit());
return process.Output;
}
}

0 comments on commit a1344e1

Please sign in to comment.