diff --git a/gm_build.go b/gm_build.go index 8208f7d..8888f0c 100644 --- a/gm_build.go +++ b/gm_build.go @@ -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) @@ -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") diff --git a/go.mod b/go.mod index 1e31312..bda6d64 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 0f7d215..aeed1ae 100644 --- a/go.sum +++ b/go.sum @@ -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=