Skip to content

Commit

Permalink
Fixing file globbing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
spekary committed Nov 24, 2024
1 parent eab2038 commit 26e8c2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
# Test binary, build with `go test -c`
*.test

#OSs
.DS_Store

#IDEs
.idea
19 changes: 19 additions & 0 deletions internal/got/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 26e8c2a

Please sign in to comment.