Skip to content

Commit

Permalink
fix version and dep optional (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee authored Jun 11, 2024
1 parent f138dbe commit 28be4db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 10 additions & 2 deletions cmd/protobuild/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package protobuild
import (
"bytes"
"fmt"
"github.com/a8m/envsubst"
"io"
"io/fs"
"os"
Expand All @@ -12,7 +11,7 @@ import (
"strings"
"sync"

_ "github.com/a8m/envsubst"
"github.com/a8m/envsubst"
"github.com/cnf/structhash"
"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/errors"
Expand Down Expand Up @@ -340,6 +339,10 @@ func Main() *cli.App {
continue
}

if pathutil.IsNotExist(url) && dep.Optional != nil && *dep.Optional {
continue
}

v := strutil.FirstFnNotEmpty(func() string {
return versions[url]
}, func() string {
Expand Down Expand Up @@ -422,6 +425,11 @@ func Main() *cli.App {
fmt.Println(url)

url = assert.Must1(filepath.Abs(url))

if pathutil.IsNotExist(url) && dep.Optional != nil && *dep.Optional {
continue
}

newUrl := filepath.Join(cfg.Vendor, dep.Name)
assert.Must(filepath.Walk(url, func(path string, info fs.FileInfo, err error) (gErr error) {
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions cmd/protobuild/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ type plugin struct {
}

type depend struct {
Name string `yaml:"name,omitempty"`
Url string `yaml:"url,omitempty"`
Path string `yaml:"path,omitempty"`
Version *string `yaml:"version,omitempty"`
Name string `yaml:"name,omitempty"`
Url string `yaml:"url,omitempty"`
Path string `yaml:"path,omitempty"`
Version *string `yaml:"version,omitempty"`
Optional *bool `yaml:"optional,omitempty"`
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/pubgo/funk/assert"
)

var Version = "v0.0.1-dev"
var Version = "v0.0.20"

func init() {
if Version == "" {
Expand Down

0 comments on commit 28be4db

Please sign in to comment.