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

ExerciseResultsSanVal => Bug fix: path of the results file opened

parent bef7705e
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment