Skip to content

Commit a8cf263

Browse files
Updated write File
1 parent 90fa86c commit a8cf263

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

cmd/main.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,23 @@ func postRun(cmd *cobra.Command, args []string) error {
166166
cfg := config.LoadConfig("2ms", Version)
167167

168168
if Report.TotalItemsScanned > 0 {
169-
if zerolog.GlobalLevel() != zerolog.Disabled || len(reportPathVar) > 0 {
169+
170+
if zerolog.GlobalLevel() != zerolog.Disabled {
170171
output, err := Report.GetOutput(stdoutFormatVar, cfg)
171172
if err != nil {
172173
return err
173174
}
174175

175-
if zerolog.GlobalLevel() != zerolog.Disabled {
176-
if err := Report.ShowReport(output); err != nil {
177-
return err
178-
}
176+
if err := Report.ShowReport(output); err != nil {
177+
return err
179178
}
179+
}
180180

181-
if len(reportPathVar) > 0 {
182-
if err := Report.WriteFile(output, reportPathVar, cfg); err != nil {
183-
log.Printf("Failed to write report: %v", err)
184-
}
181+
if len(reportPathVar) > 0 {
182+
if err := Report.WriteFile(reportPathVar, cfg); err != nil {
183+
log.Printf("Failed to write report: %v", err)
185184
}
186185
}
187-
} else {
188-
log.Info().Msg("Scan completed with empty content")
189186
}
190187

191188
return nil

lib/reporting/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (r *Report) ShowReport(output string) error {
3333
return nil
3434
}
3535

36-
func (r *Report) WriteFile(output string, reportPath []string, cfg *config.Config) error {
36+
func (r *Report) WriteFile(reportPath []string, cfg *config.Config) error {
3737
for _, path := range reportPath {
3838
err := os.MkdirAll(filepath.Dir(path), 0750)
3939
if err != nil {

0 commit comments

Comments
 (0)