Skip to content

Commit

Permalink
chore: throw error on validation fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayden Naydenov committed Jan 17, 2024
1 parent 15e257e commit 335bb0e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/tools/lib/cem/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ let validate = ajv.compile(internalSchema)
if (validate(inputDataInternal)) {
console.log('Validation internal custom-elements successful');
} else {
console.error('Validation of internal custom-elements failed:', argv.ui5package ? validate.errors : "");
if (argv.ui5package) {
throw new Error(`Validation of internal custom-elements failed: ${validate.errors}`);
} else {
console.error('Validation of internal custom-elements failed')
}
}

validate = ajv.compile(extenalSchema)
Expand All @@ -61,5 +65,9 @@ if (validate(inputDataExternal)) {
fs.writeFileSync(inputFilePath, JSON.stringify(inputDataExternal, null, 2), 'utf8');
fs.writeFileSync(inputFilePath.replace("custom-elements", "custom-elements-internal"), JSON.stringify(inputDataInternal, null, 2), 'utf8');
} else {
console.error('Validation of external custom-elements failed:', argv.ui5package ? validate.errors : "" );
if (argv.ui5package) {
throw new Error(`Validation of external custom-elements failed: ${validate.errors}`);
} else {
console.error('Validation of external custom-elements failed')
}
}

0 comments on commit 335bb0e

Please sign in to comment.