From 26e8c2a5f070943a11f50d70137fb0bda5a2830e Mon Sep 17 00:00:00 2001 From: spekary Date: Sun, 24 Nov 2024 15:38:13 -0800 Subject: [PATCH] Fixing file globbing bug --- .gitignore | 3 +++ internal/got/runner.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.gitignore b/.gitignore index a0f1211..e4ea9cc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,8 @@ # Test binary, build with `go test -c` *.test +#OSs +.DS_Store + #IDEs .idea diff --git a/internal/got/runner.go b/internal/got/runner.go index 045c17c..d012414 100644 --- a/internal/got/runner.go +++ b/internal/got/runner.go @@ -41,6 +41,10 @@ func Run(outDir string, return err } + if outDir, err = filepath.Abs(outDir); err != nil { + return err + } + if inputDirectory != "" { inputDirectory = getRealPath(inputDirectory) if inputDirectory[len(inputDirectory)-1] != filepath.Separator { @@ -230,6 +234,10 @@ func getRealPath(path string) string { log.Fatal(err) } newPath = filepath.FromSlash(newPath) + newPath, err = filepath.Abs(path) + if err != nil { + log.Fatal(err) + } return newPath } @@ -295,6 +303,17 @@ func gatherFiles(inFiles []string, inputDir string, outputDir string, suffix str f, _ := filepath.Glob(dir + "/*." + suffix) inFiles = append(inFiles, f...) } + } else { + // anchor input files + var newFiles []string + for _, f := range inFiles { + matches, _ := filepath.Glob(f) + for _, m := range matches { + m, _ = filepath.Abs(m) + newFiles = append(newFiles, m) + } + } + inFiles = newFiles } if force {