Skip to content

Commit

Permalink
SAVEPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
IT-VBFK committed Jan 7, 2023
1 parent ad5febc commit 3286252
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Build/Build.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using LibGit2Sharp;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
Expand All @@ -28,7 +30,7 @@ class Build : NukeBuild
- Microsoft VSCode https://nuke.build/vscode
*/

public static int Main() => Execute<Build>(x => x.Push);
public static int Main() => Execute<Build>(x => x.SpellCheck, x => x.Push);

[Parameter("A branch specification such as develop or refs/pull/1775/merge")]
readonly string BranchSpec;
Expand All @@ -45,6 +47,9 @@ class Build : NukeBuild
[GitVersion(Framework = "net6.0")]
readonly GitVersion GitVersion;

[GitRepository]
readonly GitRepository GitRepository;

[PackageExecutable("nspec", "NSpecRunner.exe", Version = "3.1.0")]
Tool NSpec3;

Expand Down Expand Up @@ -258,11 +263,24 @@ class Build : NukeBuild
});

Target SpellCheck => _ => _
.OnlyWhenDynamic(() => DocumentationChangesDetected())
.Executes(() =>
{
Node($"{YarnCli} install --silent", workingDirectory: RootDirectory);
Node($"{YarnCli} --silent run cspell --no-summary", workingDirectory: RootDirectory,
customLogger: (_, msg) => Error(msg));
});

bool DocumentationChangesDetected()
{
using var repo = new Repository(GitRepository.LocalDirectory);

var paths = repo.Diff.Compare<TreeChanges>(repo.Branches["develop"].Tip.Tree,
repo.Branches[repo.Head.FriendlyName].Tip.Tree)
.Where(x => x.Exists)
.Select(x => x.Path);

return paths.Any(x => x.StartsWith("docs"));
}
bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.InvariantCultureIgnoreCase);
}
1 change: 1 addition & 0 deletions Build/_build.csproj
Expand Up @@ -22,6 +22,7 @@
<PackageDownload Include="ReportGenerator" Version="[5.1.13]" />
<PackageDownload Include="xunit.runner.console" Version="[2.4.2]" />
<PackageDownload Include="Node.js.redist" Version="[16.17.1]" />
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />
<PackageReference Include="Nuke.Common" Version="6.3.0" />
<PackageDownload Include="Yarn.MSBuild" Version="[1.22.19]" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"version": "1.0.0",
"scripts": {
"cspell": "cspell --config ./cSpell.json ./**/*.md --no-progress"
"cspell": "cspell --config ./cSpell.json ./docs/**/*.md --no-progress"
},
"dependencies": {
"cspell": "^6.18.1"
Expand Down

0 comments on commit 3286252

Please sign in to comment.