Skip to content

fix(@angular/cli): remove double console logs with different reporters #9529

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

Merged
merged 1 commit into from
Feb 13, 2018
Merged
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
19 changes: 17 additions & 2 deletions packages/@angular/cli/plugins/karma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,23 @@ function requestBlocker() {
}

// Strip the server address and webpack scheme (webpack://) from error log.
const initSourcemapReporter: any = function (this: any, baseReporterDecorator: any) {
const initSourcemapReporter: 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 () {};
}

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

this.onSpecComplete = function (_browser: any, result: any) {
Expand All @@ -260,7 +275,7 @@ const initSourcemapReporter: any = function (this: any, baseReporterDecorator: a
};
};

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

module.exports = Object.assign({
'framework:@angular/cli': ['factory', init],
Expand Down