Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cSpell to NUKE build pipeline #2086

Merged
merged 19 commits into from Jan 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 5 additions & 12 deletions Build/Build.cs
Expand Up @@ -49,8 +49,8 @@ class Build : NukeBuild
[PackageExecutable("nspec", "NSpecRunner.exe", Version = "3.1.0")]
Tool NSpec3;

[PathExecutable("cspell")]
Tool CSpell;
[PathExecutable("bash")]
Tool Bash;

AbsolutePath ArtifactsDirectory => RootDirectory / "Artifacts";

Expand Down Expand Up @@ -252,27 +252,20 @@ class Build : NukeBuild
});

Target Spellcheck => _ => _
.OnlyWhenDynamic(() => !IsLocalBuild)
IT-VBFK marked this conversation as resolved.
Show resolved Hide resolved
.Executes(() =>
{
InstallCSpell();

var cSpellFile = RootDirectory / "cSpell.json";
var docsDirectory = RootDirectory / "docs";
CSpell($"--config {cSpellFile} \"{docsDirectory}/**/*.md\" --no-progress");
Bash($"-c \"cspell --config {cSpellFile} '{docsDirectory}/**/*.md' --no-progress\"");
IT-VBFK marked this conversation as resolved.
Show resolved Hide resolved
});

private void InstallCSpell()
IT-VBFK marked this conversation as resolved.
Show resolved Hide resolved
{
var output = CSpell("--help");

if (IsCSpellInstalled(output))
{
Npm("install -g cspell");
}
Npm("install -g cspell");
}

private bool IsCSpellInstalled(IReadOnlyCollection<Output> output) =>
!output.Any(o => o.Text == "Usage: cspell [options] [command]");

bool IsTag => BranchSpec != null && BranchSpec.Contains("refs/tags", StringComparison.InvariantCultureIgnoreCase);
}