这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"turbo/internal/backends"
"turbo/internal/config"
"turbo/internal/fs"
"turbo/internal/fs/globby"
"turbo/internal/globby"
"turbo/internal/util"

mapset "github.com/deckarep/golang-set"
Expand Down Expand Up @@ -180,7 +180,7 @@ func WithGraph(rootpath string, config *config.Config) Option {
globalDeps := make(util.Set)

if len(pkg.Turbo.GlobalDependencies) > 0 {
f := globby.GlobFiles(rootpath, &pkg.Turbo.GlobalDependencies, nil)
f := globby.GlobFiles(rootpath, pkg.Turbo.GlobalDependencies, []string{})
for _, val := range f {
globalDeps.Add(val)
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func WithGraph(rootpath string, config *config.Config) Option {
"**/tests/**/*",
}

f := globby.GlobFiles(rootpath, &justJsons, &ignore)
f := globby.GlobFiles(rootpath, justJsons, ignore)

for i, val := range f {
_, val := i, val // https://golang.org/doc/faq#closures_and_goroutines
Expand Down
9 changes: 6 additions & 3 deletions cli/internal/fs/copy_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ func WalkMode(rootPath string, callback func(name string, isDir bool, mode os.Fi
} else if !info.IsDir() {
return callback(rootPath, false, info.Mode())
}
return godirwalk.Walk(rootPath, &godirwalk.Options{Callback: func(name string, info *godirwalk.Dirent) error {
return callback(name, info.IsDir(), info.ModeType())
}})
return godirwalk.Walk(rootPath, &godirwalk.Options{
Callback: func(name string, info *godirwalk.Dirent) error {
return callback(name, info.IsDir(), info.ModeType())
},
Unsorted: true,
})
}

// SameFile returns true if the two given paths refer to the same physical
Expand Down
79 changes: 0 additions & 79 deletions cli/internal/fs/globby/globby.go

This file was deleted.

47 changes: 47 additions & 0 deletions cli/internal/globby/globby.go
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
}
4 changes: 2 additions & 2 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"turbo/internal/context"
"turbo/internal/core"
"turbo/internal/fs"
"turbo/internal/fs/globby"
"turbo/internal/globby"
"turbo/internal/scm"
"turbo/internal/ui"
"turbo/internal/util"
Expand Down Expand Up @@ -583,7 +583,7 @@ func (c *RunCommand) Run(args []string) int {
if runOptions.cache && (pipeline.Cache == nil || *pipeline.Cache) {
targetLogger.Debug("caching output", "outputs", outputs)
ignore := []string{}
filesToBeCached := globby.GlobFiles(pack.Dir, &outputs, &ignore)
filesToBeCached := globby.GlobFiles(pack.Dir, outputs, ignore)
if err := turboCache.Put(pack.Dir, hash, int(time.Since(cmdTime).Milliseconds()), filesToBeCached); err != nil {
c.logError(targetLogger, "", fmt.Errorf("Error caching output: %w", err))
}
Expand Down