Log warnings, fail on errors (#848)

This commit is contained in:
Sam Stern
2018-08-01 11:39:07 -07:00
committed by Michael Bleigh
parent e51b1a7b54
commit d2bb8a1bb9

View File

@@ -93,11 +93,11 @@ RulesDeploy.prototype = {
var self = this;
return gcp.rules.testRuleset(self.options.project, files).then(function(response) {
if (response.body && response.body.issues && response.body.issues.length > 0) {
var add = response.body.issues.length === 1 ? "" : "s";
var message = "Compilation error" + add + " in " + chalk.bold(filename) + ":\n";
var warnings = [];
var errors = [];
response.body.issues.forEach(function(issue) {
message +=
"\n[" +
var issueMessage =
"[" +
issue.severity.substring(0, 1) +
"] " +
issue.sourcePosition.line +
@@ -105,9 +105,26 @@ RulesDeploy.prototype = {
issue.sourcePosition.column +
" - " +
issue.description;
if (issue.severity === "ERROR") {
errors.push(issueMessage);
} else {
warnings.push(issueMessage);
}
});
return utils.reject(message, { exit: 1 });
if (warnings.length > 0) {
warnings.forEach(function(warning) {
utils.logWarning(warning);
});
}
if (errors.length > 0) {
var add = errors.length === 1 ? "" : "s";
var message =
"Compilation error" + add + " in " + chalk.bold(filename) + ":\n" + errors.join("\n");
return utils.reject(message, { exit: 1 });
}
}
utils.logSuccess(