Skip to content

Commit

Permalink
fix(tooling): use logger from settings in parallel execution (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebugusey authored Jul 11, 2024
1 parent 4636b14 commit 74ff103
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions source/Nuke.Tooling/Configure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public static T InvokeSafe<T>([CanBeNull] this Configure<T> configurator, T obj)
public static IReadOnlyCollection<(TSettings Settings, IReadOnlyCollection<Output> Output)> Invoke<TSettings>(
this CombinatorialConfigure<TSettings> configurator,
Func<TSettings, IReadOnlyCollection<Output>> executor,
Action<OutputType, string> logger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
Expand All @@ -38,15 +37,13 @@ public static T InvokeSafe<T>([CanBeNull] this Configure<T> configurator, T obj)
configurator,
x => (Settings: x, Output: executor(x)),
x => x.Output,
logger,
degreeOfParallelism,
completeOnFailure);
}

public static IReadOnlyCollection<(TSettings Settings, TResult Result, IReadOnlyCollection<Output> Output)> Invoke<TSettings, TResult>(
this CombinatorialConfigure<TSettings> configurator,
Func<TSettings, (TResult Result, IReadOnlyCollection<Output> Output)> executor,
Action<OutputType, string> logger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
Expand All @@ -55,7 +52,6 @@ public static T InvokeSafe<T>([CanBeNull] this Configure<T> configurator, T obj)
configurator,
x => (Settings: x, ReturnValue: executor(x)),
x => x.ReturnValue.Output,
logger,
degreeOfParallelism,
completeOnFailure)
.Select(x => (x.Settings, x.ReturnValue.Result, x.ReturnValue.Output)).ToList();
Expand All @@ -65,7 +61,6 @@ private static IReadOnlyCollection<TResult> Invoke<TSettings, TResult>(
CombinatorialConfigure<TSettings> configurator,
Func<TSettings, TResult> executor,
Func<TResult, IReadOnlyCollection<Output>> outputSelector,
Action<OutputType, string> logger,
int degreeOfParallelism,
bool completeOnFailure)
where TSettings : ToolSettings, new()
Expand Down Expand Up @@ -106,10 +101,17 @@ private static IReadOnlyCollection<TResult> Invoke<TSettings, TResult>(
invocations
.Where(x => x.Settings.ProcessLogOutput ?? ProcessTasks.DefaultLogOutput)
.SelectMany(x =>
x.Exception is not ProcessException processException
? outputSelector(x.Result)
: processException.Process.Output)
.ForEach(x => logger(x.Type, x.Text));
{
var (settings, result, exception) = x;
var output = exception switch
{
ProcessException processException => processException.Process.Output,
_ => outputSelector(result),
};
return output.Select(x => (Logger: settings.ProcessLogger, Line: x));
})
.ForEach(x => x.Logger(x.Line.Type, x.Line.Text));
}
}
}
Expand Down

0 comments on commit 74ff103

Please sign in to comment.