From 3563356a83b78e0d8fe5afb43a3abc09c432b570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Thu, 18 Jan 2024 01:06:21 +0100 Subject: [PATCH] ExerciseRunHelper => Update log function & display results --- NodeApp/src/helpers/Dojo/ExerciseRunHelper.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/NodeApp/src/helpers/Dojo/ExerciseRunHelper.ts b/NodeApp/src/helpers/Dojo/ExerciseRunHelper.ts index 49635d0..90cbd48 100644 --- a/NodeApp/src/helpers/Dojo/ExerciseRunHelper.ts +++ b/NodeApp/src/helpers/Dojo/ExerciseRunHelper.ts @@ -89,10 +89,10 @@ class ExerciseRunHelper { const validationResults = SharedAssignmentHelper.validateDescriptionFile(path.join(options.path, ClientsSharedConfig.assignment.filename)); if ( !validationResults.isValid ) { - spinner.fail(`The ${ ClientsSharedConfig.assignment.filename } file is invalid: ${ JSON.stringify(validationResults.errors) }`); + spinner.fail(`The ${ ClientsSharedConfig.assignment.filename } file is invalid: ${ validationResults.error }`); return; } else { - assignmentFile = validationResults.results!; + assignmentFile = validationResults.content!; } haveResultsVolume = assignmentFile.result.volume !== undefined; @@ -139,14 +139,18 @@ class ExerciseRunHelper { let spinner: ora.Ora; if ( verbose ) { - let buildPhase: boolean = true; + let buildPhase: boolean | undefined = undefined; exerciseDockerCompose.events.on('logs', (log: string, _error: boolean, displayable: boolean, currentStep: string) => { for ( const line of log.split('\n') ) { - if ( currentStep == 'COMPOSE_RUN' && buildPhase && line != '' && !line.startsWith('#') ) { + if ( displayable && buildPhase == undefined && line.startsWith('#') ) { + buildPhase = true; + } + + if ( currentStep == 'COMPOSE_RUN' && buildPhase === true && line != '' && !line.startsWith('#') ) { buildPhase = false; } - if ( displayable && (options.superVerbose || !buildPhase) ) { + if ( displayable && (options.superVerbose || buildPhase === false) ) { console.log(line); } } @@ -248,11 +252,12 @@ class ExerciseRunHelper { // Step 4: Display results + Volume location { + const info = chalk.magenta.bold.italic; ClientsSharedExerciseHelper.displayExecutionResults(exerciseResultsValidation.exerciseResults!, exerciseDockerCompose.exitCode, { - INFO : chalk.bold, + INFO : info, SUCCESS: chalk.green, FAILURE: chalk.red - }, `\n\n${ chalk.bold('Execution results folder') } : ${ this.folderResultsVolume }`); + }, `\n\n${ info('Execution results folder: ') }${ this.folderResultsVolume }`); } } } -- GitLab