1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-06 16:56:57 +02:00
This commit is contained in:
Pomax
2017-03-26 11:24:40 -07:00
parent d4b8dcd396
commit 6fcf9c9378
11 changed files with 3813 additions and 192 deletions

View File

@@ -0,0 +1,33 @@
/**********************************************************************
*
* This script is a JS handling aggregator that grabs all handler.js
* files defined for any section, and turns it into a giant master
* handler file for later use, keyed on section dir names.
*
**********************************************************************/
var fs = require("fs-extra");
var glob = require('glob');
var path = require("path");
var jsxshim = require("./lib/jsx-shim");
const BASEDIR = path.join(__dirname, "..");
var index = require(path.join(BASEDIR, "components/sections"));
var handlers = [];
Object.keys(index).forEach( section => {
var handlerFile = path.join(BASEDIR, `components/sections/${section}/handler.js`);
if (fs.existsSync(handlerFile)) {
let content = fs.readFileSync(handlerFile).toString();
content = content.replace("module.exports = ","return ");
content = `(function() { ${content} }())`;
let def = ` ${section}: {
handler: ${content}`;
if (content.indexOf('keyHandlingOptions') > -1) { def += `,\n withKeys: true`; }
def += `\n }`;
handlers.push(def);
}
});
var masterFile = `module.exports = {\n${ handlers.join(',\n') }\n};\n`;
fs.writeFileSync(path.join(BASEDIR, "lib/site/handlers.js"), masterFile);