Skip to content

Commit

Permalink
⚡ Add --verbose command for gulp lintI18n
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmoMyzrailGorynych committed Jul 2, 2022
1 parent 832e8cf commit c2dd105
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var channelPostfix = argv.channel || false,
fixEnabled = argv.fix || false,
nightly = argv.nightly || false,
buildNumber = argv.buildNum || false;
var verbose = argv.verbose || false;

if (nightly) {
channelPostfix = 'nightly';
Expand Down Expand Up @@ -311,7 +312,7 @@ const lintTags = () => {
.pipe(eslint.failAfterError());
};

const lintI18n = () => require('./node_requires/i18n')().then(console.log);
const lintI18n = () => require('./node_requires/i18n')(verbose).then(console.log);

const lint = gulp.series(lintJS, lintTags, lintStylus, lintI18n);

Expand Down
8 changes: 6 additions & 2 deletions node_requires/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const getSuitableBreakpoint = (percent, short) => {
return 'WTF?';
};

module.exports = async () => {
module.exports = async (verbose) => {
const fileNames = (await fs.readdir('./app/data/i18n')).filter(file =>
path.extname(file) === '.json' &&
file !== 'Comments.json' &&
Expand All @@ -117,10 +117,14 @@ module.exports = async () => {
// eslint-disable-next-line no-nested-ternary
`Coverage: ${report.stats[lang]}% ${getSuitableBreakpoint(report.stats[lang])}
Not translated: ${report.untranslated[lang].length}` +
(report.untranslated[lang].length > 0 ? '\n' + report.untranslated[lang].map(key => ` ${key}`).join('\n') : '') +
((verbose && report.untranslated[lang].length > 0) ? '\n' + report.untranslated[lang].map(key => ` ${key}`).join('\n') : '') +
`\nExcess: ${report.excess[lang].length} ${report.excess[lang].length ? '⚠️ '.repeat(Math.min(10, report.excess[lang].length)) : '✅'}\n` +
(report.excess[lang].length > 0 ? report.excess[lang].map(key => ` ${key}`).join('\n') : '')).join('\n\n');

if (!verbose) {
reportText += '\n👉 Use --verbose flag to log all the untranslated keys.';
}

reportText += '\n\nStats:\n';
for (const lang in report.stats) {
reportText += ` ${getSuitableBreakpoint(report.stats[lang], true)} ${report.stats[lang]}% ${lang}\n`;
Expand Down

0 comments on commit c2dd105

Please sign in to comment.