Skip to content

Commit

Permalink
fix(build): limit locales to valid files when using the --all-lang op…
Browse files Browse the repository at this point in the history
…tion (#4486)

This change updates the code path that is invoked when the build is run
using the `--all-lang` option. When assembling the list of locale files
from the `/locales` directory, this change only includes files that
satisfy _both_ of the following criteria:

- Does not start with `_`
- Ends with `.json`

This effectively excludes `_template.json` and `README.md`, and may
proactively filter out future utility files that do not follow the
typical locale-file naming standard.

Closes: #4485
  • Loading branch information
isner authored Jun 3, 2024
1 parent 6699ee4 commit d3db593
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ module.exports = function (grunt) {
});
} else if (grunt.option('all-lang')) {
var localeFiles = require('fs').readdirSync('./locales');
langs = localeFiles.map(function (file) {
return '.' + file.replace('.json', '');
});
langs = localeFiles
.filter(function (file) {
return !file.startsWith('_') && file.endsWith('.json');
})
.map(function (file) {
return '.' + file.replace('.json', '');
});
langs.unshift(''); // Add default
} else {
langs = [''];
Expand Down

0 comments on commit d3db593

Please sign in to comment.