Skip to content

Commit

Permalink
Append new lines to end of json files before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
joshAtRula committed Dec 12, 2024
1 parent 22c9b28 commit 6fcb50d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/utils/json_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ func WriteToFileAsJSON(filePath string, data any, fileMode os.FileMode) error {
return err
}

// Ensure that the JSON content ends with a newline
if len(indentedJSON) == 0 || indentedJSON[len(indentedJSON)-1] != '\n' {
indentedJSON = append(indentedJSON, '\n')
}

err = os.WriteFile(filePath, indentedJSON, fileMode)
if err != nil {
return err
Expand Down

0 comments on commit 6fcb50d

Please sign in to comment.