Open
Description
I would like support for ordering when concatenating files. I still have old Javascript files in which the order is important.
Something like:
.Concatenate(path=> path.Contains("module.js") ? 2 : 1)
The Concatenator class can be modified to use:
internal class Concatenator : Processor
{
private Func<int>? _pathPriorityFunc = null;
public Concatenator(Func<int>? pathPriorityFunc = null)
{
_pathPriorityFunc = pathPriorityFunc;
}
public override Task ExecuteAsync(IAssetContext context)
{
var sb = new StringBuilder();
var keys = _pathPriorityFunc != null ? context.Content.Keys.Order(Comparer<string>.Create(Compare)) : context.Content.Keys;
foreach (var k in keys)
{
sb.AppendLine(context.Content[k].AsString());
}
....
private static int Compare(string x, string y)
{
int prioX = _pathPriorityFunc(x);
int prioY = _pathPriorityFunc(y);
if (prioX < prioY)
return -1;
if (prioX > prioY)
return 1;
return 0;
}
Metadata
Assignees
Labels
No labels