scratch-www/test/localization-legacy/check_valid_json.js

24 lines
525 B
JavaScript
Raw Permalink Normal View History

const fs = require('fs');
const glob = require('glob');
const tap = require('tap');
2019-07-17 14:56:48 -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) {
tap.fail(`${name} has invalid Json.\n`);
2019-07-17 14:56:48 -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();
});