<commit_before>using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

var target = Argument("target", "Default");
var exercise = Argument<string>("exercise", null);

var sourceDir = "./exercises";
var buildDir  = "./build";

var solutionPath = buildDir + "/Exercises.sln";

var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = System.Environment.ProcessorCount };

Task("Clean")
    .Does(() => {
		CleanDirectory(buildDir);   
    }); 

// Copy everything to build so we make no changes in the actual files.
Task("CopyExercises")
    .IsDependentOn("Clean")
    .Does(() => {
        CopyDirectory($"{sourceDir}/{exercise}", $"{buildDir}/{exercise}");
    });

Task("EnableAllTests")
    .IsDependentOn("CopyExercises")
    .Does(() => {
        var skipRegex = new Regex(@"Skip = ""Remove to run test""", RegexOptions.Compiled);
        var testFiles = GetFiles(buildDir + "/*/*Test.fs");

        foreach (var testFile in testFiles) {
            var contents = System.IO.File.ReadAllText(testFile.FullPath);

            if (skipRegex.IsMatch(contents)) {
                var updatedContents = skipRegex.Replace(contents, "");
                System.IO.File.WriteAllText(testFile.FullPath, updatedContents);
            }
        }
    });

Task("TestRefactoringProjects")
    .IsDependentOn("EnableAllTests")
    .Does(() => {
        var refactoringProjects = 
              GetFiles(buildDir + "/*/TreeBuilding.fsproj")
            + GetFiles(buildDir + "/*/Ledger.fsproj")
            + GetFiles(buildDir + "/*/Markdown.fsproj");

        Parallel.ForEach(refactoringProjects, parallelOptions, (project) => DotNetCoreTest(project.FullPath));
});

Task("ReplaceStubWithExample")
    .IsDependentOn("TestRefactoringProjects")
    .Does(() => {
        var projects = GetFiles(buildDir + "/*/*.fsproj");

        foreach (var project in projects) {
            var projectDir = project.GetDirectory();
            var projectName = project.GetFilenameWithoutExtension();
            var stub = projectDir.GetFilePath(projectName).AppendExtension("fs");
            var example = projectDir.GetFilePath("Example.fs");
            
            DeleteFile(stub);
            MoveFile(example, stub);
        }
    });

Task("AddPackagesUsedInExampleImplementations")
    .IsDependentOn("ReplaceStubWithExample")
    .Does(() => {
        var fparsecProjects = 
              GetFiles(buildDir + "/*/Alphametics.fsproj")
            + GetFiles(buildDir + "/*/SgfParsing.fsproj");

        foreach (var fparsecProject in fparsecProjects) {
            DotNetCoreTool(fparsecProject, "add", "package FParsec");
        }
    });

Task("TestUsingExampleImplementation")
    .IsDependentOn("AddPackagesUsedInExampleImplementations")
    .Does(() => {
        var projects = GetFiles(buildDir + "/*/*.fsproj");
        Parallel.ForEach(projects, parallelOptions, (project) => DotNetCoreTest(project.FullPath));
    });

Task("Default")
    .IsDependentOn("TestUsingExampleImplementation")
    .Does(() => { });

RunTarget(target);<commit_msg>Remove unneeded line (#351)<commit_after>using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

var target = Argument("target", "Default");
var exercise = Argument<string>("exercise", null);

var sourceDir = "./exercises";
var buildDir  = "./build";

var parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = System.Environment.ProcessorCount };

Task("Clean")
    .Does(() => {
		CleanDirectory(buildDir);   
    }); 

// Copy everything to build so we make no changes in the actual files.
Task("CopyExercises")
    .IsDependentOn("Clean")
    .Does(() => {
        CopyDirectory($"{sourceDir}/{exercise}", $"{buildDir}/{exercise}");
    });

Task("EnableAllTests")
    .IsDependentOn("CopyExercises")
    .Does(() => {
        var skipRegex = new Regex(@"Skip = ""Remove to run test""", RegexOptions.Compiled);
        var testFiles = GetFiles(buildDir + "/*/*Test.fs");

        foreach (var testFile in testFiles) {
            var contents = System.IO.File.ReadAllText(testFile.FullPath);

            if (skipRegex.IsMatch(contents)) {
                var updatedContents = skipRegex.Replace(contents, "");
                System.IO.File.WriteAllText(testFile.FullPath, updatedContents);
            }
        }
    });

Task("TestRefactoringProjects")
    .IsDependentOn("EnableAllTests")
    .Does(() => {
        var refactoringProjects = 
              GetFiles(buildDir + "/*/TreeBuilding.fsproj")
            + GetFiles(buildDir + "/*/Ledger.fsproj")
            + GetFiles(buildDir + "/*/Markdown.fsproj");

        Parallel.ForEach(refactoringProjects, parallelOptions, (project) => DotNetCoreTest(project.FullPath));
});

Task("ReplaceStubWithExample")
    .IsDependentOn("TestRefactoringProjects")
    .Does(() => {
        var projects = GetFiles(buildDir + "/*/*.fsproj");

        foreach (var project in projects) {
            var projectDir = project.GetDirectory();
            var projectName = project.GetFilenameWithoutExtension();
            var stub = projectDir.GetFilePath(projectName).AppendExtension("fs");
            var example = projectDir.GetFilePath("Example.fs");
            
            DeleteFile(stub);
            MoveFile(example, stub);
        }
    });

Task("AddPackagesUsedInExampleImplementations")
    .IsDependentOn("ReplaceStubWithExample")
    .Does(() => {
        var fparsecProjects = 
              GetFiles(buildDir + "/*/Alphametics.fsproj")
            + GetFiles(buildDir + "/*/SgfParsing.fsproj");

        foreach (var fparsecProject in fparsecProjects) {
            DotNetCoreTool(fparsecProject, "add", "package FParsec");
        }
    });

Task("TestUsingExampleImplementation")
    .IsDependentOn("AddPackagesUsedInExampleImplementations")
    .Does(() => {
        var projects = GetFiles(buildDir + "/*/*.fsproj");
        Parallel.ForEach(projects, parallelOptions, (project) => DotNetCoreTest(project.FullPath));
    });

Task("Default")
    .IsDependentOn("TestUsingExampleImplementation")
    .Does(() => { });

RunTarget(target);
{'fraction_non_alphanumeric': 0.14474327628361858, 'fraction_numerical': 0.0004889975550122249, 'mean_word_length': 3.0288903479973737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1712574', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1770, 'n_words': 312}