Skip to content

Commit

Permalink
fix: funcs
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Feb 2, 2021
1 parent a9f968c commit 779a8a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions glob.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ func WithFs(fs FileSystem) OptFunc {
// This is the default behavior.
//
// Also check MatchDirectoryAsFile.
func MatchDirectoryIncludesContents() OptFunc {
return func(opts *globOptions) {
opts.matchDirectoriesDirectly = false
}
func MatchDirectoryIncludesContents(opts *globOptions) {
opts.matchDirectoriesDirectly = false
}

// MatchDirectoryAsFile makes a match on a directory match its name only.
//
// Also check MatchDirectoryIncludesContents.
func MatchDirectoryAsFile() OptFunc {
return func(opts *globOptions) {
opts.matchDirectoriesDirectly = true
}
func MatchDirectoryAsFile(opts *globOptions) {
opts.matchDirectoriesDirectly = true
}

// MatchDirectories determines weather a matching directory should
Expand Down
6 changes: 3 additions & 3 deletions glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestGlob(t *testing.T) { // nolint:funlen

t.Run("match directories directly", func(t *testing.T) {
t.Parallel()
matches, err := Glob("/a/{b,c}", MatchDirectoryAsFile(), WithFs(testFs(t, []string{
matches, err := Glob("/a/{b,c}", MatchDirectoryAsFile, WithFs(testFs(t, []string{
"/a/b/d",
"/a/b/e/f",
"/a/c",
Expand All @@ -268,7 +268,7 @@ func TestGlob(t *testing.T) { // nolint:funlen

t.Run("match empty directory", func(t *testing.T) {
t.Parallel()
matches, err := Glob("/a/{b,c}", MatchDirectoryAsFile(), WithFs(testFs(t, []string{
matches, err := Glob("/a/{b,c}", MatchDirectoryAsFile, WithFs(testFs(t, []string{
"/a/b",
}, []string{
"/a/c",
Expand All @@ -282,7 +282,7 @@ func TestGlob(t *testing.T) { // nolint:funlen

t.Run("pattern ending with star and subdir", func(t *testing.T) {
t.Parallel()
matches, err := Glob("a/*", MatchDirectoryIncludesContents(), WithFs(testFs(t, []string{
matches, err := Glob("a/*", MatchDirectoryIncludesContents, WithFs(testFs(t, []string{
"./a/1.txt",
"./a/2.txt",
"./a/3.txt",
Expand Down

0 comments on commit 779a8a5

Please sign in to comment.