diff --git a/cmd/inspect.go b/cmd/inspect.go index a0d2cef..997b0b7 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -105,6 +105,10 @@ func expandCopyCmd(ef *earthfile.Earthfile, cp earthfile.CopyCmd) (res []string, if err != nil { return nil, fmt.Errorf("could not glob pattern '%s' in '%s': %w", cp.From, ef.Dir, err) } + res, err = expandGlobMatches(res) + if err != nil { + return nil, fmt.Errorf("could not expand glob matches in '%s': %w", ef.Dir, err) + } } else if fileutil.DirExistsBestEffort(fsFrom) { res, err = filesInDir(fsFrom) if err != nil { @@ -119,6 +123,25 @@ func expandCopyCmd(ef *earthfile.Earthfile, cp earthfile.CopyCmd) (res []string, return res, nil } +func expandGlobMatches(matches []string) ([]string, error) { + res := make([]string, 0, len(matches)) + for _, m := range matches { + if !fileutil.DirExistsBestEffort(m) { + res = append(res, m) + continue + } + + logger.DebugPrintf("Expanding files in dir %s", m) + files, err := filesInDir(m) + if err != nil { + return nil, err + } + + res = append(res, files...) + } + return res, nil +} + // '+src/bla' -> 'src', 'bla' func splitTargetFileSelector(path string) (target, selector string) { plusPos := strings.IndexRune(path, '+')