1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var ts = require("typescript");
|
4 | var logger_1 = require("./logger");
|
5 | var formatDiagnosticsHost = {
|
6 | getCanonicalFileName: function (fileName) { return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); },
|
7 | getCurrentDirectory: ts.sys.getCurrentDirectory,
|
8 | getNewLine: function () { return ts.sys.newLine; },
|
9 | };
|
10 | function checkProgramDiagnosticsErrors(program) {
|
11 | checkDiagnosticsErrors(ts.getPreEmitDiagnostics(program), 'Compiled with errors');
|
12 | checkDiagnosticsErrors(program.getDeclarationDiagnostics(), 'Compiled with errors');
|
13 | }
|
14 | exports.checkProgramDiagnosticsErrors = checkProgramDiagnosticsErrors;
|
15 | function checkDiagnosticsErrors(diagnostics, failMessage) {
|
16 | if (diagnostics.length === 0) {
|
17 | return;
|
18 | }
|
19 | logger_1.errorLog(ts.formatDiagnostics(diagnostics, formatDiagnosticsHost).trim());
|
20 | throw new Error(failMessage);
|
21 | }
|
22 | exports.checkDiagnosticsErrors = checkDiagnosticsErrors;
|