Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional error summary #120

Merged
merged 2 commits into from
Jul 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions tasks/ts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 40 additions & 9 deletions tasks/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,53 @@ function pluginFn(grunt: IGrunt) {
// Level 1 errors = syntax errors - prevent JS emit.
// Level 2 errors = semantic errors - *not* prevents JS emit.
// Level 5 errors = compiler flag misuse - prevents JS emit.
var level1ErrorCount = 0, level5ErrorCount = 0, nonEmitPreventingWarningCount = 0;
var hasPreventEmitErrors = _.foldl(result.output.split('\n'), function(memo, errorMsg: string) {
var hasLevel1Errors = errorMsg.search(/error TS1\d+:/g) >= 0;
// var hasLevel2PlusErrors = errorMsg.search(/error TS[2-4,6-9]\d+:/g) >= 0;
var hasLevel5Errors = errorMsg.search(/error TS5\d+:/) >= 0;
return memo || (hasLevel1Errors || hasLevel5Errors);
var isPreventEmitError = false;
if (errorMsg.search(/error TS1\d+:/g) >= 0) {
level1ErrorCount += 1;
isPreventEmitError = true;
} else if (errorMsg.search(/error TS5\d+:/) >= 0) {
level5ErrorCount += 1;
isPreventEmitError = true;
} else if (errorMsg.search(/error TS\d+:/) >= 0) {
nonEmitPreventingWarningCount += 1;
}
return memo || isPreventEmitError;
}, false) || false;

// Because we can't think of a better way to determine it,
// assume that emitted JS in spite of error codes implies type-only errors.
var isOnlyTypeErrors = !hasPreventEmitErrors;

// Explain our interpretation of the tsc errors before we mark build results.
if (isError) {
if (isOnlyTypeErrors) {
grunt.log.writeln('Type errors only.');
}
// Log error summary
if (level1ErrorCount + level5ErrorCount + nonEmitPreventingWarningCount > 0) {
if (level1ErrorCount + level5ErrorCount > 0) {
grunt.log.write(('>> ').red);
} else {
grunt.log.write(('>> ').green);
}

if (level5ErrorCount > 0) {
grunt.log.write(level5ErrorCount.toString() + ' compiler flag error' +
(level5ErrorCount === 1 ? '' : 's') + ' ');
}
if (level1ErrorCount > 0) {
grunt.log.write(level1ErrorCount.toString() + ' syntax error' +
(level1ErrorCount === 1 ? '' : 's') + ' ');
}
if (nonEmitPreventingWarningCount > 0) {
grunt.log.write(nonEmitPreventingWarningCount.toString() +
' non-emit-preventing type warning' +
(nonEmitPreventingWarningCount === 1 ? '' : 's') + ' ');
}

grunt.log.writeln('');

if (isOnlyTypeErrors) {
grunt.log.write(('>> ').green);
grunt.log.writeln('Type errors only.');
}
}

// !!! To do: To really be confident that the build was actually successful,
Expand Down