From 0d6176c4aff5ff9ddf7b3b8efe7e87d2ad699da3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 18 Apr 2017 12:39:15 -0300 Subject: [PATCH] fixed config validation --- main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index e2750557f..2c499dee1 100644 --- a/main.go +++ b/main.go @@ -44,11 +44,15 @@ func main() { app.Action = func(c *cli.Context) (err error) { var file = c.String("config") cfg, err := config.Load(file) - // Allow failing to load the config file if file is not explicitly specified - if err != nil && c.IsSet("config") { - return cli.NewExitError(err.Error(), 1) + if err != nil { + // Allow file not found errors if config file was not + // 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) for _, pipe := range pipes(c.Bool("build-only")) { log.Println(pipe.Description())