Skip to content

Commit

Permalink
fix: update script, add error files information
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimeshKumar923 committed Mar 15, 2024
1 parent 8a34862 commit ba7a2a0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/validation/validate-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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}`)
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.');
}

0 comments on commit ba7a2a0

Please sign in to comment.