diff --git a/cmd/protobuild/cmd.go b/cmd/protobuild/cmd.go index 0ad630b..a12238f 100644 --- a/cmd/protobuild/cmd.go +++ b/cmd/protobuild/cmd.go @@ -3,7 +3,6 @@ package protobuild import ( "bytes" "fmt" - "github.com/a8m/envsubst" "io" "io/fs" "os" @@ -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" @@ -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 { @@ -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 { diff --git a/cmd/protobuild/config.go b/cmd/protobuild/config.go index 999686f..f87ea8c 100644 --- a/cmd/protobuild/config.go +++ b/cmd/protobuild/config.go @@ -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"` } diff --git a/version/version.go b/version/version.go index d4ca7d8..7f743ae 100644 --- a/version/version.go +++ b/version/version.go @@ -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 == "" {