Centralize deterministic JSON file writing

This commit is contained in:
2026-05-24 14:57:12 +00:00
parent ab4b252b08
commit c8efdb53d3
6 changed files with 105 additions and 54 deletions

View File

@@ -1,9 +1,6 @@
package report
import (
"encoding/json"
"os"
)
import "gitea.maximumdirect.net/eric/seriatim/internal/jsonfile"
// Severity classifies report events.
type Severity string
@@ -62,13 +59,5 @@ func Warning(stage string, module string, message string) Event {
// WriteJSON writes a deterministic JSON report.
func WriteJSON(path string, rpt Report) error {
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
enc := json.NewEncoder(file)
enc.SetIndent("", " ")
return enc.Encode(rpt)
return jsonfile.Write(path, rpt)
}