Skip to content

Commit

Permalink
fix sub plugin (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee authored Mar 4, 2025
1 parent a11b2ac commit 2f29a1d
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions cmd/protobuild/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,12 @@ func Main() *cli.Command {
continue
}

assert.Must(filepath.Walk(globalCfg.Root[i], func(path string, info fs.FileInfo, err error) error {
assert.Must(filepath.WalkDir(globalCfg.Root[i], func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

// skip dir
if !info.IsDir() {
return nil
}

// check contains proto file in dir
hasProto := lo.ContainsBy(
assert.Must1(os.ReadDir(path)),
func(item os.DirEntry) bool {
return !item.IsDir() && strings.HasSuffix(item.Name(), ".proto")
},
)
if !hasProto {
if !d.IsDir() {
return nil
}

Expand All @@ -174,6 +162,13 @@ func Main() *cli.Command {
pluginCfgPath := filepath.Join(path, protoPluginCfg)
if pathutil.IsExist(pluginCfgPath) {
pluginCfg = parsePluginConfig(pluginCfgPath)
} else {
for dir, v := range pluginMap {
if strings.HasPrefix(path, dir) {
pluginCfg = v
break
}
}
}
pluginCfg = mergePluginConfig(&globalCfg, pluginCfg)

Expand All @@ -189,6 +184,17 @@ func Main() *cli.Command {
}

for protoSourcePath, pp := range pluginMap {
// check contains proto file in dir
hasProto := lo.ContainsBy(
assert.Must1(os.ReadDir(protoSourcePath)),
func(item os.DirEntry) bool {
return !item.IsDir() && strings.HasSuffix(item.Name(), ".proto")
},
)
if !hasProto {
continue
}

var doF = func(pluginCfg *Config, protoPath string) {
data := ""
base := fmt.Sprintf("protoc -I %s -I %s", pluginCfg.Vendor, pwd)
Expand Down

0 comments on commit 2f29a1d

Please sign in to comment.