Skip to content

Commit

Permalink
fix: Fixed init command issue with binary files.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Sep 7, 2024
1 parent 4574e57 commit afdfbd1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/libs/OpenApiGenerator.Cli/Commands/InitializeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@ private static async Task HandleAsync(
Directory.CreateDirectory(directory);
}

await File.WriteAllTextAsync(
path,
Replace(resource.AsString())).ConfigureAwait(false);
var extension = Path.GetExtension(path);
if (extension.ToUpperInvariant() is ".PNG" or ".JPG" or ".JPEG" or ".GIF" or ".SVG" or ".SNK")
{
await File.WriteAllBytesAsync(
path,
resource.AsBytes()).ConfigureAwait(false);
}
else
{
await File.WriteAllTextAsync(
path,
Replace(resource.AsString())).ConfigureAwait(false);
}
}

Console.WriteLine("Done.");
Expand Down

0 comments on commit afdfbd1

Please sign in to comment.