All files / cli ResultPrinter.ts

100% Statements 16/16
100% Branches 4/4
100% Functions 1/1
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                  10x 3x       10x 3x       10x   6x     6x       10x 5x 5x 5x 5x 5x 8x     5x 5x            
/**
 * ResultPrinter
 * Prints transpiler compilation results
 */
 
import ITranspilerResult from "../transpiler/types/ITranspilerResult";
 
/**
 * Print transpiler compilation results
 */
class ResultPrinter {
  /**
   * Print pipeline compilation result
   * @param result - Transpiler result to print
   */
  static print(result: ITranspilerResult): void {
    // Print warnings
    for (const warning of result.warnings) {
      console.warn(`Warning: ${warning}`);
    }
 
    // Print conflicts
    for (const conflict of result.conflicts) {
      console.error(`Conflict: ${conflict}`);
    }
 
    // Print errors
    for (const error of result.errors) {
      // Format error with source path if available
      const location = error.sourcePath
        ? `${error.sourcePath}:${error.line}:${error.column}`
        : `${error.line}:${error.column}`;
      console.error(`Error: ${location} ${error.message}`);
    }
 
    // Summary
    if (result.success) {
      console.log("");
      console.log(`Compiled ${result.filesProcessed} files`);
      console.log(`Collected ${result.symbolsCollected} symbols`);
      console.log(`Generated ${result.outputFiles.length} output files:`);
      for (const file of result.outputFiles) {
        console.log(`  ${file}`);
      }
    } else {
      console.error("");
      console.error("Compilation failed");
    }
  }
}
 
export default ResultPrinter;