Jump To …

trurl.js

var evalList = [],
    reqList = ['log', 'scheduler', 'opcodes/', 'audioout','displayout'],
    fs, path,
    libpath, i, iMax, j, jMax,
    data, evalName, evalFilename, req, par, children, child,
    trurl;

path = require('path');
fs = require('fs');

libpath = path.dirname(fs.realpathSync(__filename));

for (i=0, iMax=evalList.length; i<iMax; i++) {
  evalName = evalList[i];
  evalFilename = path.join(libpath,evalName) + '.js';
  data = fs.readFileSync(evalFilename);
  exports[evalName] = eval(data.toString());
}

should make sure this only requires *.js files

for (i=0, iMax=reqList.length; i<iMax; i++) {
  req = reqList[i];
  if (req.slice(-1) == '/') {
    par = req.slice(0,-1);
    children = fs.readdirSync(path.join(libpath,par)); 
    exports[par] = {};
    for (j=0, jMax=children.length; j<jMax; j++) {
      child = children[j].slice(0,-3);
      exports[par][child] = require(path.join(libpath,par,child));
    }
  } else {
    exports[req] = require(path.join(libpath,req));
  }
}