Skip to content

Commit

Permalink
Add specific error that caused failures in the error (geosolutions-it…
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored May 20, 2020
1 parent ebd8e55 commit d422744
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions utility/translations/findMissingTranslations.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const compare = (a, b, path, callback) => {

const files = fs.readdirSync(TRANSLATIONS_FOLDER);
let fail = false;
let failureCauses = [];
log("##############################\n");
log("# Check i18n mandatory files #\n");
log("##############################\n");
Expand All @@ -71,6 +72,7 @@ files.forEach(file => {
const stat = fs.statSync(filePath);
let warning = 0;
let error = 0;
let errorLog = [];
if (stat.isFile()) {
log(`${file}\n`);
const obj = JSON.parse(fs.readFileSync(filePath, 'utf8'));
Expand All @@ -82,7 +84,9 @@ files.forEach(file => {
break;
case 'error':
error++;
log(`-->\t${path} ${mess}\n`);
const e = `-->\t${path} ${mess}\n`;
log(e);
errorLog.push(e);
break;
default:
break;
Expand All @@ -93,11 +97,16 @@ files.forEach(file => {
} else {
log(`--> ${file} FAILED\n`);
}
fail = fail || (error && isMandatory(file));
const thisFails = (error && isMandatory(file));
fail = fail || thisFails;
if (thisFails) {

failureCauses.push(`file ${file} had ${error} errors. \n ${errorLog}`);
}
log(`---------------------------\n`);
}
});
if (fail) {
throw Error("i18n files failed");
throw Error(`i18n check failure caused by: \n "${failureCauses.concat('\n')}`);
}
log('## mandatory translations checks passed!! ##\n');

0 comments on commit d422744

Please sign in to comment.