-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bcb699
commit b257126
Showing
5 changed files
with
58 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package globby | ||
|
||
import ( | ||
"turbo/internal/fs" | ||
|
||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/bmatcuk/doublestar/v4" | ||
) | ||
|
||
func GlobFiles(basePath string, includePatterns []string, excludePatterns []string) []string { | ||
var include []string | ||
var exclude []string | ||
var result []string | ||
|
||
for _, p := range includePatterns { | ||
include = append(include, filepath.Join(basePath, p)) | ||
} | ||
|
||
for _, p := range excludePatterns { | ||
exclude = append(exclude, filepath.Join(basePath, p)) | ||
} | ||
|
||
includePattern := "{" + strings.Join(include, ",") + "}" | ||
excludePattern := "{" + strings.Join(exclude, ",") + "}" | ||
_ = fs.Walk(basePath, func(p string, isDir bool) error { | ||
if val, _ := doublestar.PathMatch(excludePattern, p); val { | ||
if isDir { | ||
return filepath.SkipDir | ||
} | ||
return nil | ||
} | ||
|
||
if isDir { | ||
return nil | ||
} | ||
|
||
if val, _ := doublestar.PathMatch(includePattern, p); val || len(includePatterns) == 0 { | ||
result = append(result, p) | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b257126
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: