UNPKG

@adonisjs/require-ts

Version:
44 lines (43 loc) 1.31 kB
"use strict"; /* * @adonisjs/require-ts * * (c) Harminder Virk <virk@adonisjs.comharminder@cav.ai> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DiagnosticsReporter = void 0; /** * Exposes the API to report/print typescript diagnostic reports */ class DiagnosticsReporter { constructor(appRoot, ts, pretty) { this.appRoot = appRoot; this.ts = ts; this.pretty = pretty; /** * Diagnostics host */ this.host = { getNewLine: () => this.ts.sys.newLine, getCurrentDirectory: () => this.appRoot, getCanonicalFileName: this.ts.sys.useCaseSensitiveFileNames ? (fileName) => fileName : (fileName) => fileName.toLowerCase(), }; } report(diagnostics) { if (!diagnostics.length) { return; } if (this.pretty) { console.log(this.ts.formatDiagnosticsWithColorAndContext(diagnostics, this.host)); } else { console.log(this.ts.formatDiagnostics(diagnostics, this.host)); } } } exports.DiagnosticsReporter = DiagnosticsReporter;