const serverPath = require("./serverPath.js") const boards = require(serverPath+"/board/boards.js"); const fs = require("fs"); const { pageTop, pageBottom } = require(serverPath+"/html.js") const { exec } = require("child_process"); console.log(boards); for (let board = 0; board < boards.length; board++) { let boardPath = `${serverPath}/board/${boards[board]}/index.html`; fs.readFile(boardPath, (err, data) => { if (err) { console.log(`File /${boards[board]}/index.html doesn't exist... Creating`) fs.writeFile(`${boardPath}`,`
`, function (err) { if (err) throw err; console.log('Created page'); }); exec('node write_comments.js', (error, stdout, stderr) => { if (error) { console.error(`Error: ${error.message}`); return; } console.log(`Child script output: ${stdout}`); }); exec('node template.js', (error, stdout, stderr) => { if (error) { console.error(`Error: ${error.message}`); return; } console.log(`Child script output: ${stdout}`); }); }; if (!err && data) { console.log(`File exists: ${boards[board]}`) } }); }