troygoode / node-require-directory

Recursively iterates over specified directory, requiring each file, and returning a nested hash structure containing those libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Avoid passing module as the first argument or make it optional

davebaol opened this issue · comments

What about using parent-module or directly callsites to avoid the need of passing module as the first argument?

Currently to achieve this result I have to use a proxy module like that

var requireDirectory = require('require-directory');
var parentModule = require('parent-module');

module.exports = function(path, options) {
  return requireDirectory(require.cache[parentModule()], path, options);
}

It would be nice to have this feature supported directly.