INNER CODE UNIT · JavaScript

reportDiagnostics

postalsys/postal-mime · scripts/build.js:28

function reportDiagnostics(diagnostics, project) {
    if (diagnostics.length) {
        console.error(ts.formatDiagnosticsWithColorAndContext(diagnostics, formatHost));
        throw new Error(`${project}: compilation failed`);
    }
}

// Compiles one tsconfig project the way `tsc -p` does, with optional custom
// transformers, which the command line has no way to pass
function compile(project, customTransformers) {
    const parsed = ts.getParsedCommandLineOfConfigFile(
        path.join(root, project),
        {},
        { ...ts.sys, onUnRecoverableConfigFileDiagnostic: diagnostic => reportDiagnostics([diagnostic], project) }
    );
    reportDiagnostics(parsed.errors, project);

    const program = ts.createProgram({ rootNames: parsed.fileNames, options: parsed.options });

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…