2017-08-15 09:32:18 -04:00
|
|
|
var fs = require('fs');
|
|
|
|
var glob = require('glob');
|
|
|
|
var tap = require('tap');
|
|
|
|
|
2019-03-27 06:36:22 -04:00
|
|
|
var TRANSLATIONS_PATTERN = './node_modules/scratch-l10n/www/**/*.json';
|
2017-08-15 09:32:18 -04:00
|
|
|
var files = glob.sync(TRANSLATIONS_PATTERN);
|
|
|
|
|
2018-01-30 10:33:15 -05:00
|
|
|
const checkJson = (data, name) => {
|
2017-08-15 09:32:18 -04:00
|
|
|
try {
|
|
|
|
JSON.parse(data);
|
|
|
|
} catch (e) {
|
|
|
|
tap.fail(name + ' has invalid Json.\n');
|
|
|
|
}
|
2018-01-30 10:33:15 -05:00
|
|
|
};
|
2017-08-15 09:32:18 -04:00
|
|
|
|
2019-01-11 12:15:58 -05:00
|
|
|
tap.test('check valid json', function (t) {
|
|
|
|
files.forEach(function (f) {
|
|
|
|
const data = fs.readFileSync(f);
|
|
|
|
checkJson(data, f);
|
2017-08-15 09:32:18 -04:00
|
|
|
});
|
2019-01-11 12:15:58 -05:00
|
|
|
t.pass();
|
|
|
|
t.end();
|
2017-08-15 09:32:18 -04:00
|
|
|
});
|