Skip to content

Commit

Permalink
refactor: simplify for
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 committed Nov 9, 2020
1 parent 9935b87 commit c125fe3
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions internal/extrafiles/extra_files.go
Expand Up @@ -14,23 +14,24 @@ import (
func Find(files []config.ExtraFile) (map[string]string, error) {
var result = map[string]string{}
for _, extra := range files {
if extra.Glob != "" {
files, err := zglob.Glob(extra.Glob)
if err != nil {
return result, fmt.Errorf("globbing failed for pattern %s: %w", extra.Glob, err)
if extra.Glob == "" {
continue
}
files, err := zglob.Glob(extra.Glob)
if err != nil {
return result, fmt.Errorf("globbing failed for pattern %s: %w", extra.Glob, err)
}
for _, file := range files {
info, err := os.Stat(file)
if err == nil && info.IsDir() {
log.Debugf("ignoring directory %s", file)
continue
}
for _, file := range files {
info, err := os.Stat(file)
if err == nil && info.IsDir() {
log.Debugf("ignoring directory %s", file)
continue
}
var name = filepath.Base(file)
if old, ok := result[name]; ok {
log.Warnf("overriding %s with %s for name %s", old, file, name)
}
result[name] = file
var name = filepath.Base(file)
if old, ok := result[name]; ok {
log.Warnf("overriding %s with %s for name %s", old, file, name)
}
result[name] = file
}
}
return result, nil
Expand Down

1 comment on commit c125fe3

@vercel
Copy link

@vercel vercel bot commented on c125fe3 Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.