diff --git a/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts b/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts index 608e406f7d11b3b4178e925265c958b9459d574e..37217d4349ea0eea9421b50edc68fb41e4965e63 100644 --- a/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts +++ b/helpers/Dojo/ExerciseResultsSanitizerAndValidator.ts @@ -33,11 +33,11 @@ class ExerciseResultsSanitizerAndValidator { this.events.emit('endStep', 'RESULTS_FILE_SANITIZATION', 'Results file sanitized', false); } - private async resultsFileProvided(): Promise<boolean> { + private async resultsFileProvided(path: string): Promise<boolean> { // Results file schema validation { this.events.emit('step', 'VALIDATE_RESULTS_FILE', 'Validating results file schema'); - const validationResults = SharedExerciseHelper.validateResultFile(this.resultsFilePath); + const validationResults = SharedExerciseHelper.validateResultFile(path); if ( !validationResults.isValid ) { this.events.emit('endStep', 'VALIDATE_RESULTS_FILE', `Results file is not valid. Here are the errors :\n${ JSON.stringify(validationResults.errors) }`, true); this.events.emit('finished', false, ExerciseCheckerError.EXERCISE_RESULTS_FILE_SCHEMA_NOT_VALID); @@ -84,7 +84,7 @@ class ExerciseResultsSanitizerAndValidator { if ( fs.existsSync(resultsFileOriginPath) ) { this.events.emit('endStep', 'CHECK_RESULTS_FILE_EXIST', 'Results file found', false); - result = await this.resultsFileProvided(); + result = await this.resultsFileProvided(resultsFileOriginPath); if ( result ) { fs.rmSync(resultsFileOriginPath, { force: true }); @@ -98,7 +98,7 @@ class ExerciseResultsSanitizerAndValidator { } if ( result ) { - fs.writeFileSync(this.resultsFilePath, JSON5.stringify(this.exerciseResults), 'utf8'); + fs.writeFileSync(this.resultsFilePath, JSON5.stringify(this.exerciseResults, { space: 4 }), 'utf8'); this.events.emit('finished', true, 0); }