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

refactor(@angular-devkit/build-angular): mute internal reporters #11238

Merged
merged 3 commits into from
Aug 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,29 @@ function requestBlocker() {
};
}

// Copied from "karma-jasmine-diff-reporter" source code:
// In case, when multiple reporters are used in conjunction
// with initSourcemapReporter, they both will show repetitive log
// messages when displaying everything that supposed to write to terminal.
// So just suppress any logs from initSourcemapReporter by doing nothing on
// browser log, because it is an utility reporter,
// unless it's alone in the "reporters" option and base reporter is used.
function muteDuplicateReporterLogging(context: any, config: any) {
context.writeCommonMsg = function () { };
const reporterName = '@angular/cli';
const hasTrailingReporters = config.reporters.slice(-1).pop() !== reporterName;

if (hasTrailingReporters) {
context.writeCommonMsg = function () { };
}
}

// Emits builder events.
const eventReporter: any = function (this: any, baseReporterDecorator: any) {
const eventReporter: any = function (this: any, baseReporterDecorator: any, config: any) {
baseReporterDecorator(this);

muteDuplicateReporterLogging(this, config);

this.onRunComplete = function (_browsers: any, results: any) {
if (results.exitCode === 0) {
successCb && successCb();
Expand All @@ -237,25 +256,13 @@ const eventReporter: any = function (this: any, baseReporterDecorator: any) {
}
};

eventReporter.$inject = ['baseReporterDecorator'];
eventReporter.$inject = ['baseReporterDecorator', 'config'];

// Strip the server address and webpack scheme (webpack://) from error log.
const sourceMapReporter: any = function (this: any, baseReporterDecorator: any, config: any) {
baseReporterDecorator(this);

const reporterName = '@angular/cli';
const hasTrailingReporters = config.reporters.slice(-1).pop() !== reporterName;

// Copied from "karma-jasmine-diff-reporter" source code:
// In case, when multiple reporters are used in conjunction
// with initSourcemapReporter, they both will show repetitive log
// messages when displaying everything that supposed to write to terminal.
// So just suppress any logs from initSourcemapReporter by doing nothing on
// browser log, because it is an utility reporter,
// unless it's alone in the "reporters" option and base reporter is used.
if (hasTrailingReporters) {
this.writeCommonMsg = function () { };
}
muteDuplicateReporterLogging(this, config);

const urlRegexp = /\(http:\/\/localhost:\d+\/_karma_webpack_\/webpack:\//gi;

Expand Down