index.js 384 B

123456789101112
  1. var fs = require('fs'),
  2. glob = require('glob'),
  3. path = require('path'),
  4. classes = {},
  5. dir = __dirname;
  6. glob.sync(dir + "/**/*.js", {ignore:[dir +"/index.js"]} ).forEach( function( file ) {
  7. var className = fs.readFileSync(file, "utf8").trim().split("\n")[0].split("class")[1].replace("{", "").trim();
  8. classes[className] = require(path.resolve(file));
  9. });
  10. module.exports = classes;