Skip to content

Commit

Permalink
clear stale static report on skip report option
Browse files Browse the repository at this point in the history
Signed-off-by: Emily McMullan <[email protected]>
  • Loading branch information
eemcmullan committed Oct 25, 2023
1 parent 2323b77 commit 77cfa93
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,22 @@ func (a *analyzeCommand) CreateJSONOutput() error {
}

func (a *analyzeCommand) GenerateStaticReport(ctx context.Context) error {
// check for stale static report dir
staticReportDir := filepath.Join(a.output, "static-report")
stat, err := os.Stat(staticReportDir)
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
return err
}
}
if stat != nil && a.skipStaticReport {
a.log.Info("clearing stale static report", "report", staticReportDir)
err := os.RemoveAll(staticReportDir)
if err != nil {
return err
}
return nil
}
if a.skipStaticReport {
return nil
}
Expand All @@ -687,7 +703,7 @@ func (a *analyzeCommand) GenerateStaticReport(ctx context.Context) error {
container := NewContainer(a.log)
a.log.Info("generating static report",
"output", a.output, "args", strings.Join(staticReportCmd, " "))
err := container.Run(
err = container.Run(
ctx,
WithEntrypointBin("/bin/sh"),
WithEntrypointArgs(staticReportCmd...),
Expand Down

0 comments on commit 77cfa93

Please sign in to comment.