lib/looseleaf.js
function loadModules(dir, container, args) {
  var files = fs.readdirSync(dir);
  for (var i = 0; i < files.length; i++) {
    var file = files[i];
    var filePath = path.join(dir, file);
    if (fs.statSync(filePath).isDirectory()) {
      container[file] = {};
      loadModules(filePath, container[file], args);
      continue;
    }
    if (/.+\.js$/.test(file)) {
      var name = file.replace(/\.js$/, '') 
      container[name] = require(filePath)(args, container);
    }
  }
}
function loadModules(dir, container, args) {
  var files = fs.readdirSync(dir);
  for (var i = 0; i < files.length; i++) {
    var file = files[i];
    var filePath = path.join(dir, file);
    if (fs.statSync(filePath).isDirectory()) {
      container[file] = {};
      loadModules(filePath, container[file], args);
      continue;
    }
    if (/.+\.js$/.test(file)) {
      var name = file.replace(/\.js$/, '') 
      container[name] = require(filePath)(args, container);
    }
  }
}
function loadModules ( dir , container , args ) { var files = fs . readdirSync ( dir ) ; for ( var i = 0 ; i < files . length ; i ++ ) { var file = files [ i ] ; var filePath = path . join ( dir , file ) ; if ( fs . statSync ( filePath ) . isDirectory ( ) ) { container [ file ] = { } ; loadModules ( filePath , container [ file ] , args ) ; continue ; } if ( / .+\.js$ / . test ( file ) ) { var name = file . replace ( / \.js$ / , '' ) container [ name ] = require ( filePath ) ( args , container ) ; } } }
Load and require js files to container obj from dir
Load and require js files to container obj from dir