1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-09-16 09:26:52 +02:00

fixed config validation

This commit is contained in:
Carlos Alexandro Becker
2017-04-18 12:39:15 -03:00
parent 8ca628195d
commit 0d6176c4af

12
main.go
View File

@@ -44,11 +44,15 @@ func main() {
app.Action = func(c *cli.Context) (err error) { app.Action = func(c *cli.Context) (err error) {
var file = c.String("config") var file = c.String("config")
cfg, err := config.Load(file) cfg, err := config.Load(file)
// Allow failing to load the config file if file is not explicitly specified if err != nil {
if err != nil && c.IsSet("config") { // Allow file not found errors if config file was not
return cli.NewExitError(err.Error(), 1) // explicitly specified
_, statErr := os.Stat(file)
if !os.IsNotExist(statErr) || c.IsSet("config") {
return cli.NewExitError(err.Error(), 1)
}
} }
ctx := context.New(cfg) var ctx = context.New(cfg)
log.SetFlags(0) log.SetFlags(0)
for _, pipe := range pipes(c.Bool("build-only")) { for _, pipe := range pipes(c.Bool("build-only")) {
log.Println(pipe.Description()) log.Println(pipe.Description())