Skip to content

Commit

Permalink
fix: truncating pre-existing output file when overwritten (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-hilti authored May 21, 2024
1 parent 8e3dbeb commit bf0e305
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cyclonedx/CliUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static async Task<int> OutputBomHelper(Bom bom, CycloneDXBomFormat format
}
}

using var stream = filename == null ? Console.OpenStandardOutput() : File.OpenWrite(filename);
using var stream = filename == null ? Console.OpenStandardOutput() : File.Create(filename);

switch (format)
{
Expand Down Expand Up @@ -193,7 +193,7 @@ public static async Task<int> OutputBomHelper(Bom bom, ConvertFormat format, Spe

bom.SpecVersion = outputVersion.HasValue ? outputVersion.Value : SpecificationVersionHelpers.CurrentVersion;

using var stream = filename == null ? Console.OpenStandardOutput() : File.OpenWrite(filename);
using var stream = filename == null ? Console.OpenStandardOutput() : File.Create(filename);

switch (format)
{
Expand Down

0 comments on commit bf0e305

Please sign in to comment.