Created
June 9, 2018 10:24
-
-
Save Mansh05/54ea3ca5d051dec8eafbc0582459a594 to your computer and use it in GitHub Desktop.
Revisions
-
Mansh05 created this gist
Jun 9, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ let fs = require('fs'); let checkJson = (path) => { fs.readdir(path, (err, files) => { files.forEach(file => { if (fs.lstatSync(`${path}/${file}`).isDirectory()) { checkJson(`${path}/${file}`) } else { readFile(`${path}/${file}`); } }); }); } let readFile = (path) => { let aa = fs.createReadStream(path, 'utf8'); aa.on('data', (chunk) => { try { JSON.parse(chunk); // console.log(JSON.parse(chunk)); } catch (e) { console.log('There is an error in' + path); process.exit(1); } }); } checkJson('./demo');