Recursively requires the modules in current dir.

@param  {String}  dir  The base directory to require entities from.
@return {Object}       An object with all the modules loaded.
320128
function requireMethods(dir) {
  if (!dir) dir = getCallerDirname();

  var modules = {};

  fs
    .readdirSync(dir)
    .filter(function(filename) {
      return filename !== 'index.js';
    })
    .forEach(function(filename) {
      var filePath = path.join(dir, filename);
      var Stats = fs.lstatSync(filePath);
      var isLink = Stats.isSymbolicLink();
      var isDir = Stats.isDirectory();
      var isFile = Stats.isFile();
      var isJS = filename.indexOf('.js') > -1;

      if (!isLink && isDir) {
        modules[filename] = requireMethods(filePath);
      }

      else if (!isLink && isFile && isJS) {
        var entityName = filename.replace('.js', '');
        modules[entityName] = require(filePath);

        var hasES6Default = isObject(modules[entityName])
          && isFunction(modules[entityName].default);

        if (hasES6Default) {
          modules[entityName] = modules[entityName].default;
        }
      }
    });

  return modules;
}
1203195
function loadDir(dir, db, callback) {
    callback = callback || function() {};
    
    //Get the absolute dir path if a relative path was given
    if (dir.substr(0, 1) !== '/') {
        var parentPath = module.parent.filename.split('/');
        parentPath.pop();
        dir = parentPath.join('/') + '/' + dir;
    }
    
    //Load each file in directory
    fs.readdir(dir, function(err, files){
        if (err) return callback(err);
        
        var iterator = function(file, next){
            loadFile(dir + '/' + file, db, next);
        };
        async.forEach(files, iterator, callback);
    });
}
1350158
function emptyDir(dir) {
  return new Promise((resolve, reject) => {
    FS.emptyDir(dir, err => {
      err ? reject(err) : resolve(dir);
    })
  });
}
203563
function(dir, files){		
		fs.readdirSync(dir).forEach(function(file){
			try{
				var current = path.join(dir, file);
				var stat = fs.statSync(current);
				if (stat && stat.isDirectory()) {
					getAllFiles(current, files);
				}else {
				    files.push(current);
				}
			}catch(e){
				console.error(e);
			}
        });
	}
243429
function define(id, deps, exp) {
		if (!exp) { exp = deps; deps = [ 'require', 'exports', 'module' ]; }
		var module = getModule(undefined, id);
		module.children = map(deps, function(dep) { return getModule(module, dep); });
		module.loaded = true;
		factories[id] = exp;
		fireWaits(module);
	}
1293099
function getModules(directory, logger, local) {
    logger(`Getting modules @ ${directory.path}`);
    if (directory.barrel) {
        // If theres a barrel then use that as it *should* contain descendant modules.
        logger(`Found existing barrel @ ${directory.barrel.path}`);
        return [directory.barrel];
    }
    const files = [].concat(directory.files);
    if (!local) {
        directory.directories.forEach((childDirectory) => {
            // Recurse.
            files.push(...getModules(childDirectory, logger, local));
        });
    }
    // Only return files that look like TypeScript modules.
    return files.filter((file) => file.name.match(utilities_1.isTypeScriptFile));
}
1306844
function load(rulesDir) {
  var newRules = loadRules(rulesDir);
  Object.keys(newRules).forEach(function(ruleId) {
    define(ruleId, newRules[ruleId]);
  });
}
245727
function specialRequire(name, fromDir) {
	if (!fromDir) fromDir = process.cwd();
	var paths = Module._nodeModulePaths(fromDir);
	var path = Module._findPath(name, paths);
	return path ? require(path) : require(name);
}
833422
function createDir(dir) {
  const splitPath = dir.split('/');
  splitPath.reduce((path, subPath) => {
    let currentPath;
    if(subPath != '.'){
      currentPath = path + '/' + subPath;
      if (!fs.existsSync(currentPath)){
        fs.mkdirSync(currentPath);
      }
    }
    else{
      currentPath = subPath;
    }
    return currentPath
  }, '')
}
1064145
function local_require(submod) {
			// Resolve local module symbol
			if(submod.slice(0, 1) === ".") {
				submod = path.join(path.dirname(sym.path), submod);

				// Outside bundle
				if(submod.slice(0, 2) === "..") {
					throw null; // Will be catched by the try{} in require
				}
			}
			
			// Try given name, if fails, add ".js" and try again
			var submod_sym;
			try {
				submod_sym = __nld.resolve(submod);
			} catch(e) {
				submod_sym = __nld.resolve(submod + ".js");
			}
			
			// Detect cycles
			function find_cycle_root(leaf) {
				if(leaf.id === submod_sym) {
					return leaf;
				} else if(leaf.parent) {
					return find_cycle_root(leaf.parent);
				} else {
					return false;
				}
			}
			
			var cycle_root = find_cycle_root(module);
			if(cycle_root) {
				return cycle_root.exports;
			}
			
			return __nld(submod_sym, undefined, module);
		}
827132
function defaultMigrationLoader(dir) {
    let list = new List;
    
    return new Promise((resolve, reject) => {
        fs.readdir(dir, function(err, files) {
            if (err) return reject(err);
            
            const migrationFiles = files.filter((file) => file.match(/^\d+.*\.js$/)).sort();
            
            migrationFiles.forEach((file) => {
                let mod;
                try {
                    mod = require(path.join(dir, file));
                }
                catch (err) {
                    return reject(err);
                }
                
                list = list.addMigration(file, mod.up, mod.down);
            });
            
            resolve(list);
        });
    });
}
1118254
public Launcher dir(FileNode dir) {
        return dir(dir.toPath().toFile(), dir.getWorld().getSettings().encoding);
    }
667910
function getModuleMapSync(dir) {
  var map = {};

  fs
    .readdirSync(dir)
    .filter(function(filename) {
      return filename !== 'index.js';
    })
    .forEach(function(filename) {
      var filePath = path.join(dir, filename);
      var Stats = fs.lstatSync(filePath);
      var isLink = Stats.isSymbolicLink();
      var isDir = Stats.isDirectory();
      var isFile = Stats.isFile();
      var isJS = filename.indexOf('.js') > -1;

      if (!isLink && isDir) {
        map[filename] = getModuleMapSync(filePath);
      }

      else if (!isLink && isFile && isJS) {
        var entityName = filename.replace('.js', '');
        map[entityName] = true;
      }
    });

  return map;
}
666450
function load(dirPath) {

    findFiles(dirPath, function(filePath){
        collection.push( require(filePath) );
    })

    function findFiles(dirPath, callback){
        fs.readdir(dirPath, function(err, files) {
            files.forEach(function(file){
                fs.stat(dirPath + '/' + file, function(err, stats) {
                    if(stats.isFile()) {
                        callback(dirPath + '/' + file);
                    }
                    if(stats.isDirectory()) {
                        getDirectoryFiles(dirPath + '/' + file, callback);
                    }
                });
            });
        });
    }
}
422875
function createDirectory(dir) {
    if (!fs.existsSync(dir)) {
        dryRun ? console.log(`...CREATE the '${dir}' folder.`) : fs.mkdirSync(dir);
    }
}
431669
function listdir(dir, rules, root, included) {
  return fs.readdir(dir)
  .then(function(files) {
    return when.all(files.map(function(f) {
      f = path.join(dir, f);
      return when(fs.stat(f), function(stat) {
        return {
          path: f,
          isDirectory: stat.isDirectory()
        };
      });
    }));
  })
  .then(function(arr) {
    var files = [];
    var subdirs = [];
    arr.forEach(function(e) {
      if (e.isDirectory) {
        subdirs.push(e.path);
      } else {
        files.push(e.path);
      }
    });
    files = files.filter(function(f) {
      return filter(f, rules, root, false, included);
    });
    return when.all(subdirs.map(function(d) {
      return listdir(d, rules, root, filter(d, rules, root, true, included));
    }))
    .then(function(list) {
      list = list.reduce(function(ret, i) {
        return ret.concat(i);
      }, files);
      // include current dir only if at least one of its children is included
      if (list.length > 0) {
        list.push(dir);
      }
      return list;
    });
  });
}
393777
function requirePath(fromPath, require) {
  // console.log('requirePath:fromPath: ' + fromPath);
  // console.log('requirePath:require: ' + require);
  if (fromPath === null || fromPath === undefined
    || require === null || require === undefined) {
    return null;
  }
  var filePath = path.resolve(path.dirname(fromPath), require);
  return realRequirPath(filePath);
}