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-20 08:40:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var compileOk = function () {
|
|
|
|
var msg = process.argv[2];
|
|
|
|
if (msg && msg.match(/failed/)) {
|
|
|
|
console.log("Compilation failed");
|
|
|
|
// beep
|
|
|
|
console.log('\u0007');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
2014-01-05 10:16:01 +00:00
|
|
|
|
2014-01-20 08:40:56 +00:00
|
|
|
if (compileOk()) {
|
|
|
|
console.log('Writing site');
|
|
|
|
try {
|
|
|
|
generate();
|
|
|
|
} catch (e) {
|
|
|
|
console.log('\u0007');
|
|
|
|
console.error(e.stack);
|
|
|
|
}
|
|
|
|
}
|