@@ -14,7 +14,6 @@ import (
14
14
15
15
"github.com/iancoleman/strcase"
16
16
"github.com/launchdarkly/ld-find-code-refs/internal/helpers"
17
- "github.com/launchdarkly/ld-find-code-refs/internal/log"
18
17
"github.com/launchdarkly/ld-find-code-refs/internal/validation"
19
18
"github.com/launchdarkly/ld-find-code-refs/options"
20
19
)
@@ -28,10 +27,7 @@ func GenerateAliases(flags []string, aliases []options.Alias, dir string) (map[s
28
27
29
28
ret := make (map [string ][]string , len (flags ))
30
29
for _ , flag := range flags {
31
- for i , a := range aliases {
32
- if a .Name == "" {
33
- a .Name = strconv .Itoa (i )
34
- }
30
+ for _ , a := range aliases {
35
31
flagAliases , err := generateAlias (a , flag , dir , allFileContents )
36
32
if err != nil {
37
33
return nil , err
@@ -45,7 +41,6 @@ func GenerateAliases(flags []string, aliases []options.Alias, dir string) (map[s
45
41
46
42
func generateAlias (a options.Alias , flag , dir string , allFileContents map [string ][]byte ) ([]string , error ) {
47
43
ret := []string {}
48
- aliasId := a .Name
49
44
switch a .Type .Canonical () {
50
45
case options .Literal :
51
46
ret = a .Flags [flag ]
@@ -68,7 +63,7 @@ func generateAlias(a options.Alias, flag, dir string, allFileContents map[string
68
63
absGlob := filepath .Join (dir , path )
69
64
matches , err := filepath .Glob (absGlob )
70
65
if err != nil {
71
- return nil , fmt .Errorf ("filepattern '%s': could not process path glob '%s'" , aliasId , absGlob )
66
+ return nil , fmt .Errorf ("could not process path glob '%s'" , absGlob )
72
67
}
73
68
for _ , match := range matches {
74
69
pathFileContents := allFileContents [match ]
@@ -106,11 +101,11 @@ func generateAlias(a options.Alias, flag, dir string, allFileContents map[string
106
101
cmd .Dir = dir
107
102
stdout , err := cmd .Output ()
108
103
if err != nil {
109
- return nil , fmt .Errorf ("filepattern '%s': failed to execute alias command: %w" , aliasId , err )
104
+ return nil , fmt .Errorf ("failed to execute alias command: %w" , err )
110
105
}
111
106
err = json .Unmarshal (stdout , & ret )
112
107
if err != nil {
113
- return nil , fmt .Errorf ("filepattern '%s': could not unmarshal json output of alias command: %w" , aliasId , err )
108
+ return nil , fmt .Errorf ("could not unmarshal json output of alias command: %w" , err )
114
109
}
115
110
}
116
111
@@ -134,12 +129,9 @@ func processFileContent(aliases []options.Alias, dir string) (map[string][]byte,
134
129
for _ , glob := range a .Paths {
135
130
absGlob := filepath .Join (dir , glob )
136
131
matches , err := filepath .Glob (absGlob )
137
- if err != nil {
132
+ if matches == nil || err != nil {
138
133
return nil , fmt .Errorf ("filepattern '%s': could not process path glob '%s'" , aliasId , absGlob )
139
134
}
140
- if matches == nil {
141
- log .Info .Printf ("filepattern '%s': no matching files found for alias path glob '%s'" , aliasId , absGlob )
142
- }
143
135
paths = append (paths , matches ... )
144
136
}
145
137
paths = helpers .Dedupe (paths )
0 commit comments