public AssetComponents GetGlobComponentsForAsset(IEnumerable<string> assetPaths, string basePath) { var files = new List<string>(); var excludes = new List<string>(); var dependencies = new List<string>(); foreach (var path in assetPaths) { if (path.StartsWith("!")) { excludes.AddRange(Glob.Expand(Path.Combine(basePath, path.Substring(1))).Select(f => f.FullName)); } else if (path.StartsWith("+")) { dependencies.AddRange(Glob.Expand(Path.Combine(basePath, path.Substring(1))).Select(f => f.FullName)); } else { files.AddRange(Glob.Expand(Path.Combine(basePath, path)).Select(f => f.FullName)); } } excludes.AddRange(dependencies); var components = new AssetComponents(); dependencies.ForEach(o => components.Dependencies.Add(() => ReadFile(o))); files.Except(excludes).ForEach(o => components.Files.Add(() => ReadFile(o))); return components; }
public async Task<string> BundleAsync(AssetComponents components) { var results = await Task.WhenAll( Task.WhenAll(components.Dependencies.Select(o => o())), Task.WhenAll(components.Files.Select(o => o())) ); var sb = new StringBuilder(); foreach (var res in results) { res.Aggregate(sb, (builder, s) => builder.AppendLine(s)); } return sb.ToString(); }