Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- let files = fs.readdirSync('.').filter((file) => { return file.includes('.json') && file !== 'db.json' });
- let concat={};
- files.forEach(function(file){
- let fileContent=fs.readFileSync(file, 'utf8');
- concat[file.split('.json')[0]]=JSON.parse(fileContent);
- })
- fs.writeFile('./db.json', JSON.stringify(concat), 'utf8', (e, d) => {
- console.info("Generado db.json.");
- console.info("Ejecute \x1b[36mjson-server --watch db.json\x1b[0m para levantar JSON-Server");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement