Skip to content

Commit

Permalink
Add support to write Json file
Browse files Browse the repository at this point in the history
Fixes #129
  • Loading branch information
Christian Bumann committed Aug 7, 2023
1 parent 89328d6 commit 801ba15
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Cake.Markdownlint.Tests.NodeJs
{
using Cake.Core;
using Shouldly;
using Xunit;

Expand Down Expand Up @@ -54,6 +55,18 @@ public void OutputFile_Should_Be_Added_If_Settings_Are_Passed()

result.Args.ShouldBe("-o \"c:/foo.log\" \"c:/directory-to-lint\"");
}

[Fact]
public void JsonFormatArgument_Should_Be_Added_If_Settings_Are_Passed()
{
var fixture = new MarkdownlintNodeJsRunnerFixture();
fixture.Settings.OutputFile = @"c:\foo.log";
fixture.Settings.JsonFormat = true;

var result = fixture.Run();

result.Args.ShouldBe("-o \"c:/foo.log\" \"c:/directory-to-lint\" -j");
}
}
}
}
10 changes: 10 additions & 0 deletions src/Cake.Markdownlint/NodeJs/MarkdownlintNodeJsRunnerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ protected MarkdownlintNodeJsRunnerSettings(DirectoryPath directory)
/// </summary>
public FilePath OutputFile { get; set; }

/// <summary>
/// Gets or sets the value if the log file will be written in json format or not.
/// </summary>
public bool JsonFormat { get; set; }

/// <summary>
/// Gets or sets a value indicating whether an exception should be thrown if an issues was
/// detected.
Expand Down Expand Up @@ -92,6 +97,11 @@ internal void Evaluate(ProcessArgumentBuilder args)
{
args.AppendQuoted(this.directory.FullPath);
}

if (this.JsonFormat)
{
args.Append("-j");
}
}
}
}

0 comments on commit 801ba15

Please sign in to comment.