Examples
The following example will call markdownlint-cli to lint some markdown files and outputs the number of warnings.
To call markdownlint-cli from a Cake script you can use the Cake.Markdownlint addin.
-
In production code this dependency should be pinned to a specific version to make sure builds are deterministic and won't break due to updates.
See Reproducible Builds for details.
To read issues from markdownlint-cli log files you need to import the core addin and the markdownlint support:
#addin nuget:?package=Cake.Issues&version=5.0.1
#addin nuget:?package=Cake.Issues.Markdownlint&version=5.0.1
We need some global variables:
The following task will run markdownlint-cli and write a log file:
Task("Lint-Documentation").Does(() =>
{
// Run markdownlint-cli.
var settings =
MarkdownlintNodeJsRunnerSettings.ForDirectory(repoRootPath.Combine("docs"));
settings.OutputFile = logPath;
settings.ThrowOnIssue = false;
RunMarkdownlintNodeJs(settings);
});
Finally you can define a task where you call the core addin with the desired issue provider.