Skip to content

Commit

Permalink
add support to ** patterns for build
Browse files Browse the repository at this point in the history
  • Loading branch information
kpym committed Jan 25, 2024
1 parent a8616f1 commit ef330e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gm_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"path/filepath"
"strings"

"github.com/bmatcuk/doublestar/v4"
)

// buildMd compiles the infile (xxx.md | stdin) to outfile (xxx.html | stdout)
Expand Down Expand Up @@ -59,9 +61,13 @@ func buildFiles() {
buildMd("")
continue
}
// get the current directory as a filesystem, needed for doublestar.Glob
cwd, err := os.Getwd()
check(err, "Problem getting the current directory.")
dirFS := os.DirFS(cwd)
// look for all files with the given patterns
// but build only .md ones
allfiles, err := filepath.Glob(pattern)
allfiles, err := doublestar.Glob(dirFS, pattern, doublestar.WithFilesOnly(), doublestar.WithNoFollow())
check(err, "Problem looking for file pattern:", pattern)
if len(allfiles) == 0 {
info("No files found.\n")
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/alecthomas/chroma v0.10.0
github.com/bmatcuk/doublestar/v4 v4.6.1
github.com/mdigger/goldmark-attributes v0.0.0-20210529130523-52da21a6bf2b
github.com/spf13/pflag v1.0.6-0.20201009195203-85dd5c8bc61c
github.com/yuin/goldmark v1.5.6
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit ef330e7

Please sign in to comment.