fs = require('fs'); var normalizedPath = require("path").join(__dirname, "themes"); var html = "# Themes\nThis collection of themes are meant to be used with [Ronin](https://github.com/hundredrabbits/Marabu), [Left](https://github.com/hundredrabbits/Left), [Donsol](https://github.com/hundredrabbits/Donsol) and [Dotgrid](https://github.com/hundredrabbits/Dotgrid).\n\n\n\n## Install\nTo install a theme, simply drag the `thm` file onto the application window.\nYou are welcome to submit your own themes to this collection!\n\n" function build_svg(n,theme) { var name = n.split(".")[0]; var size = 16 var html = ` ` fs.writeFile("assets/"+name+".svg", html, function(err) { if(err) {return console.log(err);} console.log("Saved "+name) }); } function build_theme(n,theme) { var name = n.split(".")[0]; return `## [${name}](themes/${name}.thm)\n![${name}](assets/${name}.svg)\n\n` } function is_json(text) { try{ JSON.parse(text); return true; } catch (error){ return false; } } function generate(html) { fs.writeFile("README.md", html, function(err) { if(err) {return console.log(err);} console.log("Done.") }); } require("fs").readdirSync(normalizedPath).forEach(function(file_name) { fs.readFile('themes/'+file_name, 'utf8', function (err,data){ if(err) { return console.log(err); } if(is_json(data)){ var theme = JSON.parse(data) build_svg(file_name,theme) html += build_theme(file_name,theme) } }); }); setTimeout(function(){ generate(html); },1000)