1 | "use strict";
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
10 | exports.addError = exports.addWarning = exports.createDiagnosticsReporter = void 0;
|
---|
11 | const compiler_cli_1 = require("@angular/compiler-cli");
|
---|
12 | const typescript_1 = require("typescript");
|
---|
13 | function createDiagnosticsReporter(compilation) {
|
---|
14 | return (diagnostics) => {
|
---|
15 | for (const diagnostic of diagnostics) {
|
---|
16 | const text = compiler_cli_1.formatDiagnostics([diagnostic]);
|
---|
17 | if (diagnostic.category === typescript_1.DiagnosticCategory.Error) {
|
---|
18 | addError(compilation, text);
|
---|
19 | }
|
---|
20 | else {
|
---|
21 | addWarning(compilation, text);
|
---|
22 | }
|
---|
23 | }
|
---|
24 | };
|
---|
25 | }
|
---|
26 | exports.createDiagnosticsReporter = createDiagnosticsReporter;
|
---|
27 | function addWarning(compilation, message) {
|
---|
28 | compilation.warnings.push(new compilation.compiler.webpack.WebpackError(message));
|
---|
29 | }
|
---|
30 | exports.addWarning = addWarning;
|
---|
31 | function addError(compilation, message) {
|
---|
32 | compilation.errors.push(new compilation.compiler.webpack.WebpackError(message));
|
---|
33 | }
|
---|
34 | exports.addError = addError;
|
---|