const serverPath = require("./serverPath.js") const boards = require(serverPath+"/board/boards.js"); const fs = require("fs"); const { pageTop, pageBottom } = require(serverPath+"/html.js") console.log(boards); for (let board = 0; board < boards.length; board++) { console.log(boards[board]); let boardPath = `${serverPath}/board/${boards[board]}`; if (fs.existsSync(boardPath)) { console.log(`Directory /${boards[board]}/ exists`) } else { console.log(`Directory /${boards[board]}/ doesn't exist... Creating`) fs.mkdirSync(boardPath); fs.appendFile(`${serverPath}/board/${boards[board]}/index.html`,`

`, function (err) { if (err) throw err; console.log('Created page'); }); fs.appendFile(`${serverPath}/board/${boards[board]}/comments-database.js`,`let comments = [["ADMIN","welcome to the ${boards[board]} board"]]; if (typeof module != "undefined" && module.exports) { module.exports = comments; }`, function (err) { if (err) throw err; console.log('Created comments array'); }); fs.appendFile(`${serverPath}/board/${boards[board]}/displayComments.js`,`let divText = document.getElementById("comments").innerHTML; newPageHTML=""; for (let comment = 0; comment < comments.length; comment++) { newPageHTML+=\`\${comments[comment][0]}: \${comments[comment][1]}
\`}; document.getElementById("comments").innerHTML = newPageHTML`, function (err) { if (err) throw err; console.log('Created displaycomments.js'); }); } }