From 167a87e60d0ffe0ad780135f8fe8becc29944219 Mon Sep 17 00:00:00 2001 From: Amy Boyd Date: Thu, 22 Dec 2016 14:22:00 +0000 Subject: [PATCH] Use exit code 1 when there's a style error. --- editorconfig/check_command.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/editorconfig/check_command.go b/editorconfig/check_command.go index 75becae..0e894da 100644 --- a/editorconfig/check_command.go +++ b/editorconfig/check_command.go @@ -3,6 +3,7 @@ package editorconfig import ( "fmt" "github.com/codegangsta/cli" + "os" "strconv" "strings" ) @@ -19,6 +20,8 @@ func CheckCommand(c *cli.Context) error { configs := FindConfigFiles(files) + hasError := false + for _, f := range files { rules := GetRulesToApplyToSourcePath(f, configs) if len(rules) == 0 { @@ -32,6 +35,7 @@ func CheckCommand(c *cli.Context) error { if fullFileChecker, ok := fullFileCheckers[ruleName]; ok { result := fullFileChecker(ruleValue, fileContent) if !result.isOk { + hasError = true fmt.Println(f + ": " + ruleName + ": " + result.messageIfNotOk) } } @@ -46,6 +50,7 @@ func CheckCommand(c *cli.Context) error { result := lineChecker(ruleValue, line) if !result.isOk { fmt.Println(f + ": line " + strconv.Itoa(lineNo) + ": " + ruleName + ": " + result.messageIfNotOk) + hasError = true // Don't show more than 1 error per line. break } @@ -55,5 +60,9 @@ func CheckCommand(c *cli.Context) error { } } + if hasError { + os.Exit(1) + } + return nil }