/// <summary> /// call the chef to stir the project up ;) /// </summary> /// <param name="inputDir">the project input directory path</param> /// <param name="outputDir">the project mirror / output direcotry path</param> /// <param name="fileFilters">filters to filter files to process by</param> /// <param name="activeFlavors">list of active flavors</param> /// <param name="copyAll">should all files be copied, no matter if they were changed OR not?</param> /// <param name="markedFilesOnly">should only files marked as flavored be processed</param> static void CallChef(string inputDir, string outputDir, List <string> fileFilters, List <string> activeFlavors, bool copyAll, bool markedFilesOnly, bool parallel) { //setup filter function FileFilterWrapper filter = new FileFilterWrapper() { MatchesFilterFunc = (FileInfo file) => { //check if file should be flavored (matches filters) bool matchFilter = false; foreach (string filter in fileFilters) { //convert filter into regex string filterRegex = "^" + Regex.Escape(filter).Replace("\\*", ".*").Replace("\\?", ".") + "$"; //check filename with regex if (Regex.IsMatch(file.Name, filterRegex)) { matchFilter = true; break; } } //check first line for marking if enabled if (matchFilter && markedFilesOnly) { //get first line string firstLn = File.ReadLines(file.FullName).FirstOrDefault(); //check first line contains "flavored" marking //include all files that are marked and matched by the processing filter (flavor may have changed) return(!string.IsNullOrWhiteSpace(firstLn) && firstLn.Contains("flavored", StringComparison.OrdinalIgnoreCase)); } return(matchFilter); } }; //check input exists DirectoryInfo input = new DirectoryInfo(inputDir); if (!input.Exists) { Log.e($"project directory {inputDir} does not exist!"); return; } //create output if needed DirectoryInfo output = new DirectoryInfo(outputDir); if (!output.Exists) { output.Create(); output.Refresh(); } //create chef and start cooking :D //use defaults except for filter Chef chef = new Chef() { FlavorFilter = filter }; chef.FlavorProject(input, output, activeFlavors, parallel); }