Use exit code 1 when there's a style error.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user