UNPKG

1.01 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var ts = require("typescript");
4var logger_1 = require("../logger");
5var 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};
10function checkProgramDiagnosticsErrors(program) {
11 checkDiagnosticsErrors(ts.getPreEmitDiagnostics(program), 'Compiled with errors');
12 checkDiagnosticsErrors(program.getDeclarationDiagnostics(), 'Compiled with errors');
13}
14exports.checkProgramDiagnosticsErrors = checkProgramDiagnosticsErrors;
15function 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}
22exports.checkDiagnosticsErrors = checkDiagnosticsErrors;