mirror of
https://github.com/status-im/reagent.git
synced 2025-01-15 06:14:08 +00:00
bffbae231d
Tests and doc site can now run without node, using only "lein figwheel". Tests and site are then re-run automatically whenever a source file changes. The doc site is now generated into "outsite/public", and can be copied into the "gh-pages" branch with "make build-gh-pages". "make push-gh-pages" builds the doc site and pushes it upstream to the gh-pages branch there. Generation of html pages is now handled completely in ClojureScript, loaded from "bin/gen-site.js". Link handling is a bit simplified.
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
|
|
var fs = require("fs");
|
|
var vm = require("vm");
|
|
var path = require("path");
|
|
|
|
var loadSrc = function (mainFile, outputDir, devModule) {
|
|
var src = fs.readFileSync(mainFile);
|
|
var googDir = path.join(outputDir, "goog");
|
|
var optNone = false;
|
|
if (outputDir) {
|
|
optNone = fs.existsSync(path.join(googDir, "deps.js"));
|
|
}
|
|
|
|
if (optNone) {
|
|
var cwd = process.cwd();
|
|
if (!global.goog) global.goog = {};
|
|
|
|
global.CLOSURE_IMPORT_SCRIPT = function (src) {
|
|
require(path.resolve(path.resolve(
|
|
cwd, path.join(googDir, src))));
|
|
return true;
|
|
};
|
|
|
|
var f = path.join(googDir, "base.js");
|
|
vm.runInThisContext(fs.readFileSync(f), f);
|
|
require(path.resolve(cwd, mainFile));
|
|
goog.require(devModule);
|
|
} else {
|
|
global.globalNodeRequire = require;
|
|
|
|
vm.runInThisContext("(function (require) {"
|
|
+ src
|
|
+ "\n})(globalNodeRequire);", mainFile);
|
|
}
|
|
return optNone;
|
|
};
|
|
|
|
exports.load = loadSrc;
|