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

Merge remote-tracking branch 'origin/main' into main

parents 558f3fde 99c20f92
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,7 @@ import JSON5 from 'json5';
class ExerciceHelper {
validateResultFile(resultsFilePath: string): {
results: ExerciceResultsFile | undefined, isValid: boolean, errors: Array<ErrorObject<string, Record<string, any>, unknown> | string> | null | undefined
} {
validateResultFile(resultsFilePathOrStr: string, isFile: boolean = true): { results: ExerciceResultsFile | undefined, isValid: boolean, errors: Array<ErrorObject<string, Record<string, any>, unknown> | string> | null | undefined } {
const ajv = new Ajv();
const schema: JTDSchemaType<ExerciceResultsFile> = {
......@@ -35,7 +33,7 @@ class ExerciceHelper {
const validator = ajv.compile(schema);
try {
const results = JSON5.parse(fs.readFileSync(resultsFilePath, 'utf8'));
const results = JSON5.parse(isFile ? fs.readFileSync(resultsFilePathOrStr, 'utf8') : resultsFilePathOrStr);
const isValid = validator(results);
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment