2023-10-24 14:22:28 -04:00
|
|
|
const fs = require('fs');
|
|
|
|
const glob = require('glob');
|
|
|
|
const tap = require('tap');
|
2019-07-17 14:56:48 -04:00
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
const TRANSLATIONS_PATTERN = './node_modules/scratch-l10n/www/**/*.json';
|
|
|
|
const files = glob.sync(TRANSLATIONS_PATTERN);
|
2019-07-17 14:56:48 -04:00
|
|
|
|
|
|
|
const checkJson = (data, name) => {
|
|
|
|
try {
|
|
|
|
JSON.parse(data);
|
|
|
|
} catch (e) {
|
2023-10-24 14:22:28 -04:00
|
|
|
tap.fail(`${name} has invalid Json.\n`);
|
2019-07-17 14:56:48 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-24 14:22:28 -04:00
|
|
|
tap.test('check valid json', t => {
|
|
|
|
files.forEach(f => {
|
2019-07-17 14:56:48 -04:00
|
|
|
const data = fs.readFileSync(f);
|
|
|
|
checkJson(data, f);
|
|
|
|
});
|
|
|
|
t.pass();
|
|
|
|
t.end();
|
|
|
|
});
|