Skip to content

Commit

Permalink
Merge pull request #94 from rsteube/fix-tmpfolder-creation
Browse files Browse the repository at this point in the history
fix tmp folder creation on each invocation
  • Loading branch information
rsteube authored Oct 26, 2022
2 parents 677aa38 + d523b67 commit 7a06585
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import (
"github.com/spf13/pflag"
)

var tmpDir string = getTmpDir()

func getTmpDir() string {
func Scrape(cmd *cobra.Command) {
dir, err := os.MkdirTemp(os.TempDir(), "carascrape")
if err != nil {
panic(err.Error())
}
return dir

scrape(cmd, dir)
}

func Scrape(cmd *cobra.Command) {
func scrape(cmd *cobra.Command, tmpDir string) {
out := &bytes.Buffer{}

if len(cmd.Aliases) > 0 {
Expand Down Expand Up @@ -110,7 +109,7 @@ var %vCmd = &cobra.Command{

for _, subcmd := range cmd.Commands() {
if !subcmd.Hidden && subcmd.Deprecated == "" {
Scrape(subcmd)
scrape(subcmd, tmpDir)
}
}
}
Expand Down

0 comments on commit 7a06585

Please sign in to comment.