const fs = require("fs") const Mustache = require('mustache'); // Load template const htmlTemplate = fs.readFileSync("build/template/editor.html.mustache").toString() const nodes = fs.readdirSync("src/nodes") nodes.forEach((e)=>{ // Load html parts const helpHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`) const editorHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`) // Load complied editor index js/ts let indexHtml = fs.readFileSync(`dist/nodes/${e}/ui/index.js`).toString() // Cut first 2 lines because typescript inserts some stuff that the browser does not like // TODO: is is ugly but it works const tmp = indexHtml.split("\n") tmp.splice(0,2) indexHtml = tmp.join("\n") // Prepare view object to be injected into render const view = { helpHtml, editorHtml, indexHtml, nodeName: e } const html = Mustache.render(htmlTemplate, view); // Write generated html into dist fs.writeFileSync(`dist/nodes/${e}/${e}.html`,html) })