reagent/bin/gen-site.js

41 lines
935 B
JavaScript
Raw Normal View History

2014-01-05 10:16:01 +00:00
var cljsLoad = require("./cljs-load");
2014-01-05 10:16:01 +00:00
var srcFile = "pre-render/main.js";
var outputDirectory = "outsite/public/js/out";
var devFile = "reagenttest/runtests.js";
2014-01-09 13:37:11 +00:00
var beep = "\u0007";
2014-01-05 10:16:01 +00:00
2014-12-09 06:30:57 +00:00
if (typeof location === "undefined") {
// figwheel wants js/location to exist, even if it doesn't run,
// for some reason
global.location = {};
}
var gensite = function () {
console.log("Pre-rendering or testing...");
var optNone = cljsLoad.load(srcFile, outputDirectory, devFile);
sitetools.server.genpages({"opt-none": optNone});
2014-01-19 11:13:19 +00:00
}
var compileFail = function () {
var msg = process.argv[process.argv.length - 1];
if (msg && msg.match(/failed/)) {
console.log("Compilation failed" + beep);
2014-01-20 08:40:56 +00:00
return true;
}
2014-01-20 08:40:56 +00:00
};
2014-01-05 10:16:01 +00:00
process.env.NODE_ENV = "production";
if (!compileFail()) {
try {
gensite();
} catch (e) {
console.log(e + beep);
console.error(e.stack);
process.exit(1);
}
2014-01-20 08:40:56 +00:00
}
process.exit(0);