Skip to content

Commit

Permalink
Merge pull request #144 from eoehen/feature/add-gittagversion-argument
Browse files Browse the repository at this point in the history
(#143) Add support for npm version --git-tag-version argument
  • Loading branch information
pascalberger authored Jun 26, 2023
2 parents 697b887 + c5eeef4 commit dfb4230
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,34 @@ public void Should_Add_CommitMessage_Option_Using_Extension()
Assert.Equal("version minor -m \"Bumped minor version.\"", result.Args);
}

[Fact]
public void Should_Add_GitTagVersion_True_Switch()
{
// Given
fixture.Settings.WithVersion("11.22.33");
fixture.Settings.GitTagVersion = true;

// When
var result = fixture.Run();

// Then
Assert.Equal("version 11.22.33 --git-tag-version=true", result.Args);
}

[Fact]
public void Should_Add_GitTagVersion_False_Switch()
{
// Given
fixture.Settings.WithVersion("11.22.33");
fixture.Settings.GitTagVersion = false;

// When
var result = fixture.Run();

// Then
Assert.Equal("version 11.22.33 --git-tag-version=false", result.Args);
}

class ExtensionNullCheckData : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
Expand Down
12 changes: 12 additions & 0 deletions src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public NpmBumpVersionSettings()
/// </summary>
public string Version {get;set; }

/// <summary>
/// Gets or sets the <c>--git-tag-version</c> option.
/// Tag the commit when using the <c>npm version</c> command. Setting this to <c>true</c> results in no commit being made at all.
/// </summary>
public bool? GitTagVersion { get; set; }

/// <summary>
/// Evaluates the settings and writes them to <paramref name="args"/>.
/// </summary>
Expand All @@ -53,6 +59,12 @@ protected override void EvaluateCore(ProcessArgumentBuilder args)
{
args.Append("-f");
}

if (GitTagVersion.HasValue)
{
args.Append($"--git-tag-version={GitTagVersion.ToString().ToLowerInvariant()}");
}

}
}
}

0 comments on commit dfb4230

Please sign in to comment.