Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Oct 16, 2024
2 parents 48dca99 + abb8db3 commit b046df4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ nuspecファイルを使ってパッケージを生成する場合は、デフ

## 履歴

* 3.9.0:
* UTF8テキストファイル出力をBOMなしに変更。
* 3.8.0:
* NPM `package.json` のバージョンを自動挿入する、NPMモードを追加。
* NuGetパッケージをビルドする時に、ビルドログにバージョン番号のゴミが出力されていたのを修正。
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ When you are using a nuspec file to generate a NuGet package, there are addition

## History

* 3.9.0:
* Changed UTF8 text file output to no BOM.
* 3.8.0:
* Added NPM mode, which automatically inserts the version of NPM `package.json`.
* Fixed version number print garbage in the build log when building NuGet packages.
Expand Down
3 changes: 3 additions & 0 deletions RelaxVersioner.Core/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using GitReader;
Expand All @@ -26,6 +27,8 @@ internal static class Utilities
{
private static readonly char[] directorySeparatorChar_ =
{ Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };

public static readonly Encoding UTF8 = new UTF8Encoding(false);

public static string GetDirectoryPath(string path) =>
Path.GetDirectoryName(path) switch
Expand Down
6 changes: 3 additions & 3 deletions RelaxVersioner.Core/Writers/NpmReplaceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ void ReplaceSubKey(string key)
stream =>
{
using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
new StreamReader(rip, Utilities.UTF8, true) :
Console.In;
var tw = new StreamWriter(stream, Encoding.UTF8);
var tw = new StreamWriter(stream, Utilities.UTF8);
Replace(tr, tw);
});
Expand All @@ -108,7 +108,7 @@ void ReplaceSubKey(string key)
}

using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
new StreamReader(rip, Utilities.UTF8, true) :
Console.In;
Replace(tr, Console.Out);
}
Expand Down
6 changes: 3 additions & 3 deletions RelaxVersioner.Core/Writers/TextReplaceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void Replace(TextReader tr, TextWriter tw)
stream =>
{
using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
new StreamReader(rip, Utilities.UTF8, true) :
Console.In;
var tw = new StreamWriter(stream, Encoding.UTF8);
var tw = new StreamWriter(stream, Utilities.UTF8);
Replace(tr, tw);
});
Expand All @@ -78,7 +78,7 @@ void Replace(TextReader tr, TextWriter tw)
}

using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
new StreamReader(rip, Utilities.UTF8, true) :
Console.In;
Replace(tr, Console.Out);
}
Expand Down
2 changes: 1 addition & 1 deletion RelaxVersioner.Core/Writers/TextWriteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void Write(TextWriter tw, bool emitEol)

Processor.WriteSafeTransacted(
context.OutputPath,
stream => Write(new StreamWriter(stream, Encoding.UTF8), false));
stream => Write(new StreamWriter(stream, Utilities.UTF8), false));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion RelaxVersioner/build/RelaxVersioner.props
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
string path = Path.GetFullPath(File.ItemSpec);
using (Stream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
{
TextWriter tw = new StreamWriter(fs, Encoding.UTF8);
TextWriter tw = new StreamWriter(fs, new UTF8Encoding(false));
string text = Text;
if (text != null)
{
Expand Down

0 comments on commit b046df4

Please sign in to comment.