2017-08-15 09:32:18 -04:00
|
|
|
var fs = require('fs');
|
|
|
|
var glob = require('glob');
|
|
|
|
var tap = require('tap');
|
|
|
|
|
|
|
|
var TRANSLATIONS_PATTERN = './node_modules/scratchr2_translations/www/**/*.json';
|
|
|
|
var files = glob.sync(TRANSLATIONS_PATTERN);
|
|
|
|
|
2018-01-30 09:53:25 -05:00
|
|
|
function checkJson (data, name) {
|
2017-08-15 09:32:18 -04:00
|
|
|
try {
|
|
|
|
JSON.parse(data);
|
|
|
|
} catch (e) {
|
|
|
|
tap.fail(name + ' has invalid Json.\n');
|
|
|
|
}
|
|
|
|
tap.pass();
|
2018-01-30 09:53:25 -05:00
|
|
|
}
|
2017-08-15 09:32:18 -04:00
|
|
|
|
|
|
|
files.forEach(function (f) {
|
|
|
|
tap.test('check valid json', function (t) {
|
|
|
|
fs.readFile(f, function (err, data) {
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
checkJson(data, f);
|
|
|
|
});
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|