chore(cmd): pass max file size of changelog via options

This commit is contained in:
Felix Wiedmann
2021-05-08 20:45:24 +02:00
parent d66364e474
commit d9e5dc4515
3 changed files with 11 additions and 180 deletions

View File

@@ -196,16 +196,16 @@ func (s *SemanticRelease) GetChangelog(releaseVersion *shared.ReleaseVersion) (*
}, releaseVersion.Commits)
}
// Todo add maxMB paratemter
// WriteChangeLog writes changelog content to the given file
func (s *SemanticRelease) WriteChangeLog(changelogContent, file string, overwrite bool) error {
func (s *SemanticRelease) WriteChangeLog(changelogContent, file string, overwrite bool, maxChangelogFileSize int64) error {
info, err := os.Stat(file)
if overwrite || err != nil {
return os.WriteFile(file, []byte(changelogContent), 0644)
}
// TODO: add input of max mb and calculate correct with bytes
if info.Size() >= 1000000 {
fileSizeMB := info.Size() / 1024 / 1024 / 1024
if fileSizeMB >= maxChangelogFileSize {
err := moveExistingChangelogFile(file)
if err != nil {
return err