Skip to content

Commit

Permalink
Fix naming of generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Veld committed Jan 18, 2022
1 parent 4f430d0 commit 6267ab0
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,23 @@ var generateCmd = &cobra.Command{
log.Fatal(err)
}

hash := randSeq(4)

base := "output"
filename := ""
if csvOutputVar != "" {
base = filepath.Base(parameters[csvOutputVar])
base := filepath.Base(parameters[csvOutputVar])
filename = strings.TrimSuffix(base, filepath.Ext(base))
} else {
hash := randSeq(4)
base := "output"
file := strings.TrimSuffix(base, filepath.Ext(base))
filename = fmt.Sprintf("%s-%s", file, hash)
}

// Trim off any file extensions if present.
file := strings.TrimSuffix(base, filepath.Ext(base))
filename := fmt.Sprintf("%s-%s", file, hash)

outputPath := fmt.Sprintf("%s/%s.png", filepath.Dir(outputPath), filename)
err = generator.Generate(template, version, outputPath)
if err != nil {
log.Fatal(err)
}
}

} else {
template, err := generator.ParseTemplate(templatePath, parameters)
if err != nil {
Expand Down

0 comments on commit 6267ab0

Please sign in to comment.