1
0
mirror of https://github.com/go-task/task.git synced 2025-03-03 14:52:13 +02:00
task/internal/status/glob.go

29 lines
462 B
Go
Raw Normal View History

package status
import (
"path/filepath"
"sort"
"github.com/mattn/go-zglob"
"mvdan.cc/sh/shell"
)
func glob(dir string, globs []string) (files []string, err error) {
for _, g := range globs {
if !filepath.IsAbs(g) {
g = filepath.Join(dir, g)
}
g, err = shell.Expand(g, nil)
if err != nil {
return nil, err
}
f, err := zglob.Glob(g)
if err != nil {
return nil, err
}
files = append(files, f...)
}
sort.Strings(files)
return
}