The problem with doing this via npm is that npm works with the
dependencies from the package.json which is a problem for plugins,
since they are seldom known at the time the package.json is writeen.

I have done something like this for my app. What I ended up doing is
simply defining a folder which all plugins have to be in.

    function requirePlugins(plugindir) {
      require('fs').readdirSync(plugindir).map(function(item) {
        return require('path').resolve(plugindir, item);
      }).forEach(function(plugin) {
        if (/\.plugin$/.test(plugin)) require(plugin);
      });
    }

on start-up I simply call

    requirePlugins(require('path').resolve('./plugins'));

This avoids traversing a billion directories, and does what you need.
It is synchronous of course, but that is true for require anyhow and
does not matter much since it is ever only called on start-up.

Regards, Philipp

On Apr 21, 8:04 pm, Mike Pilsbury <mike.pilsb...@gmail.com> wrote:
> > So doing an `npm ls` from a process is the only way to go?  Whatever it
> > takes.
>
> > It looks 
> > likehttp://npmjs.org/doc/README.html#Using-npm-Programmaticallyoffers
>
> another option.

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to