@@ -148,24 +148,12 @@ func Main() *cli.Command {
148
148
continue
149
149
}
150
150
151
- assert .Must (filepath .Walk (globalCfg .Root [i ], func (path string , info fs.FileInfo , err error ) error {
151
+ assert .Must (filepath .WalkDir (globalCfg .Root [i ], func (path string , d fs.DirEntry , err error ) error {
152
152
if err != nil {
153
153
return err
154
154
}
155
155
156
- // skip dir
157
- if ! info .IsDir () {
158
- return nil
159
- }
160
-
161
- // check contains proto file in dir
162
- hasProto := lo .ContainsBy (
163
- assert .Must1 (os .ReadDir (path )),
164
- func (item os.DirEntry ) bool {
165
- return ! item .IsDir () && strings .HasSuffix (item .Name (), ".proto" )
166
- },
167
- )
168
- if ! hasProto {
156
+ if ! d .IsDir () {
169
157
return nil
170
158
}
171
159
@@ -174,6 +162,13 @@ func Main() *cli.Command {
174
162
pluginCfgPath := filepath .Join (path , protoPluginCfg )
175
163
if pathutil .IsExist (pluginCfgPath ) {
176
164
pluginCfg = parsePluginConfig (pluginCfgPath )
165
+ } else {
166
+ for dir , v := range pluginMap {
167
+ if strings .HasPrefix (path , dir ) {
168
+ pluginCfg = v
169
+ break
170
+ }
171
+ }
177
172
}
178
173
pluginCfg = mergePluginConfig (& globalCfg , pluginCfg )
179
174
@@ -189,6 +184,17 @@ func Main() *cli.Command {
189
184
}
190
185
191
186
for protoSourcePath , pp := range pluginMap {
187
+ // check contains proto file in dir
188
+ hasProto := lo .ContainsBy (
189
+ assert .Must1 (os .ReadDir (protoSourcePath )),
190
+ func (item os.DirEntry ) bool {
191
+ return ! item .IsDir () && strings .HasSuffix (item .Name (), ".proto" )
192
+ },
193
+ )
194
+ if ! hasProto {
195
+ continue
196
+ }
197
+
192
198
var doF = func (pluginCfg * Config , protoPath string ) {
193
199
data := ""
194
200
base := fmt .Sprintf ("protoc -I %s -I %s" , pluginCfg .Vendor , pwd )
0 commit comments