json-files-merger
Version:
json-files-merger
1 lines • 627 B
JavaScript
;var fs=require('fs'),jsonOperator=require('jsonfile'),jsonTemp={},load=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:'de',b='./'+a;return fs.readdirSync(b).forEach(function(a){var c=b+'/'+a;if(c.match('.json$','i')){var d=jsonOperator.readFileSync(c),e=Object.keys(d);if(0===e.length)throw new Error(c+' has NO content!');e.forEach(function(a){if(!d[a])throw new Error(c+' => KEY: '+a+' has no translation defined!');if(jsonTemp[a])throw new Error(c+' => KEY: '+a+' is duplicated!');jsonTemp[a]=d[a]})}else throw new Error(c+' is not a JSON File!')}),jsonTemp};module.exports={load:load};