diff --git a/internal/status/checksum.go b/internal/status/checksum.go index 8ffdc466..26ec493c 100644 --- a/internal/status/checksum.go +++ b/internal/status/checksum.go @@ -28,7 +28,7 @@ func (c *Checksum) IsUpToDate() (bool, error) { data, _ := ioutil.ReadFile(checksumFile) oldMd5 := strings.TrimSpace(string(data)) - sources, err := glob(c.Dir, c.Sources) + sources, err := globs(c.Dir, c.Sources) if err != nil { return false, err } diff --git a/internal/status/glob.go b/internal/status/glob.go index 305e0f9b..b46f7616 100644 --- a/internal/status/glob.go +++ b/internal/status/glob.go @@ -1,6 +1,7 @@ package status import ( + "os" "path/filepath" "sort" @@ -9,21 +10,42 @@ import ( "github.com/mattn/go-zglob" ) -func glob(dir string, globs []string) (files []string, err error) { +func globs(dir string, globs []string) ([]string, error){ + files := make([]string, 0) for _, g := range globs { - if !filepath.IsAbs(g) { - g = filepath.Join(dir, g) - } - g, err = execext.Expand(g) - if err != nil { - return nil, err - } - f, err := zglob.Glob(g) + f, err := glob(dir, g) if err != nil { continue } files = append(files, f...) } sort.Strings(files) - return + return files, nil +} + +func glob(dir string, g string) ([]string, error) { + files := make([]string, 0) + if !filepath.IsAbs(g) { + g = filepath.Join(dir, g) + } + g, err := execext.Expand(g) + if err != nil { + return nil, err + } + fs, err := zglob.Glob(g) + if err != nil { + return nil, err + } + for _, f := range fs { + info, err := os.Stat(f) + if err != nil { + continue + } + if info.IsDir() { + continue + } + files = append(files, f) + } + sort.Strings(files) + return files, nil } diff --git a/internal/status/timestamp.go b/internal/status/timestamp.go index 62b9aafb..fcc52f6a 100644 --- a/internal/status/timestamp.go +++ b/internal/status/timestamp.go @@ -19,11 +19,11 @@ func (t *Timestamp) IsUpToDate() (bool, error) { return false, nil } - sources, err := glob(t.Dir, t.Sources) + sources, err := globs(t.Dir, t.Sources) if err != nil { return false, nil } - generates, err := glob(t.Dir, t.Generates) + generates, err := globs(t.Dir, t.Generates) if err != nil { return false, nil }