reagent/bin/gen-site.js

36 lines
948 B
JavaScript
Raw Normal View History

2014-01-05 10:16:01 +00:00
#! /usr/bin/env node
var fs = require("fs");
var vm = require('vm');
2014-01-09 13:37:11 +00:00
var cssFiles = ['examples/todomvc/todos.css',
'examples/todomvc/todosanim.css',
'examples/simple/example.css',
'site/demo.css'];
2014-01-19 11:13:19 +00:00
var srcFile = "target/cljs-client.js";
var src = fs.readFileSync(srcFile);
2014-01-05 10:16:01 +00:00
2014-01-19 11:13:19 +00:00
var clj_genpages = function (profile) {
if (typeof demo === 'undefined') {
vm.runInThisContext(src, srcFile);
}
return demo.genpages(profile);
}
var generate = function () {
var pages = clj_genpages();
Object.keys(pages).map(function (page) {
fs.writeFileSync(page, pages[page]);
});
fs.writeFileSync("assets/demo.js", src);
fs.writeFileSync("assets/demo.css",
cssFiles.map(function (x) {
return fs.readFileSync(x);
}).join("\n"));
console.log('Wrote site');
}
2014-01-05 10:16:01 +00:00
console.log('Writing site');
2014-01-19 11:13:19 +00:00
generate();