diff --git a/scripts/validation/validate-examples.js b/scripts/validation/validate-examples.js index dde70104..9513a98f 100644 --- a/scripts/validation/validate-examples.js +++ b/scripts/validation/validate-examples.js @@ -5,7 +5,8 @@ const glob = require('glob'); const files = glob.sync('./examples/**/*.{yml,yaml}'); let filesCount = 0; -let validationErrors = []; // Array to store validation errors +let errorFilesCount = 0; +let filesWithErrors = []; // Array to store files that failed validation // Validate each file using AsyncAPI CLI files.forEach((file) => { filesCount++; @@ -14,9 +15,21 @@ files.forEach((file) => { execSync(`npx asyncapi validate ${file}`, { stdio: 'inherit' }); } catch (error) { console.error(`Validation failed for: ${file}\n`); + errorFilesCount++; + filesWithErrors.push(file); // process.exit(1); } }); -console.log(`\n\nValidation Completed!\nTotal files validated = ${filesCount}`) \ No newline at end of file +console.log(`\n\nValidation Completed!\nTotal files validated = ${filesCount}\nTotal files having error = ${errorFilesCount}`) + +// Display files with errors +if (filesWithErrors.length > 0) { + console.log('\nFiles with validation errors:'); + filesWithErrors.forEach((file) => { + console.log(file); + }); +} else { + console.log('\nAll files validated successfully.'); +} \ No newline at end of file