Skip to content
Snippets Groups Projects
Commit b22af108 authored by michael.minelli's avatar michael.minelli
Browse files

AssignmentHelper => Add displayExecutionResult function

parent 2a2bea69
No related branches found
No related tags found
No related merge requests found
import chalk from 'chalk';
import boxen from 'boxen';
import Icon from '../../types/Icon';
import AssignmentValidator from './AssignmentValidator';
class ClientsSharedAssignmentHelper {
displayExecutionResults(validator: AssignmentValidator, successMessage: string, Style: { INFO: chalk.Chalk, SUCCESS: chalk.Chalk, FAILURE: chalk.Chalk }) {
const finalLogGlobalResult = `${ Style.INFO('Global result') } : ${ validator.success ? Style.SUCCESS(`${ Icon.SUCCESS } Success`) : Style.FAILURE(`${ Icon.FAILURE } Failure`) }`;
const finalLogSuccessMessage = validator.success ? `${ successMessage }` : '';
const finalLogErrorMessage = !validator.success ? `${ Style.INFO('Error message') } :\n${ Style.FAILURE(validator.fatalErrorMessage) }` : '';
console.log(boxen(`${ finalLogGlobalResult }\n\n${ finalLogSuccessMessage }${ finalLogErrorMessage }`, {
title : 'Results',
titleAlignment: 'center',
borderColor : validator.success ? 'green' : 'red',
borderStyle : 'bold',
margin : 1,
padding : 1,
textAlignment : 'left'
}));
}
}
export default new ClientsSharedAssignmentHelper();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment