import * as color from "colorette" ; import * as tr from "text-runner-core" ; import * as helpers from "../helpers" ; import * as formatter from "." ; /** A minimalistic formatter, prints dots for each check */ export class DotFormatter implements formatter . Formatter { constructor ( command ) { command . on ( "output" , console . log ) ; command . on ( "result" , this . onResult . bind ( this ) ) ; } onResult ( result ) { if ( tr . events . instanceOfFailed ( result ) ) { this . onFailed ( result ) ; } else if ( tr . events . instanceOfSkipped ( result ) ) { process . stdout . write ( color . cyan ( "." ) ) ; } else if ( tr . events . instanceOfSuccess ( result ) ) { process . stdout . write ( color . green ( "." ) ) ; } else if ( tr . events . instanceOfWarning ( result ) ) { console . log ( color . magenta ( result . message ) ) ; } } onFailed ( args ) { console . log ( ) ; console . log ( color . dim ( args . output ) ) ; process . stdout . write ( color . red ( `${ args . activity . location . file . platformified ( ) }:${ args . activity . location . line } -- ` ) ) ; console . log ( args . error . message ) ; helpers . printCodeFrame ( console . log , args . activity . location ) ; } finish ( args ) { formatter . printSummary ( args . results ) ; } }