Skip to content

Commit

Permalink
fix: set format to HTML when requesting serving resutls (#1424)
Browse files Browse the repository at this point in the history
When `serve` is enabled, set the `format` to html (regardless of the
`output` flag).
  • Loading branch information
hogo6002 authored Dec 5, 2024
1 parent ee0945a commit dd77323
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cmd/osv-scanner/scan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,20 @@ func action(context *cli.Context, stdout, stderr io.Writer) (reporter.Reporter,

outputPath := context.String("output")
serve := context.Bool("serve")
if serve && outputPath == "" {
if serve {
format = "html"
// Create a temporary directory
tmpDir, err := os.MkdirTemp("", "osv-scanner-result")
if err != nil {
return nil, fmt.Errorf("failed creating temporary directory: %w\n"+
"Please use `--output result.html` to specify the output path", err)
}
if outputPath == "" {
// Create a temporary directory
tmpDir, err := os.MkdirTemp("", "osv-scanner-result")
if err != nil {
return nil, fmt.Errorf("failed creating temporary directory: %w\n"+
"Please use `--output result.html` to specify the output path", err)
}

// Remove the created temporary directory after
defer os.RemoveAll(tmpDir)
outputPath = filepath.Join(tmpDir, "index.html")
// Remove the created temporary directory after
defer os.RemoveAll(tmpDir)
outputPath = filepath.Join(tmpDir, "index.html")
}
}

termWidth := 0
Expand Down

0 comments on commit dd77323

Please sign in to comment.