Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

autodiscover-modules

Autodiscover modules in a directory with a required export signature

readme

autodiscover-modules

Autodiscover modules in a directory with a required export signature

Usage

import path from 'path';
import autodiscover 'autodiscover-modules';

const folder = path.join(__dirname, 'modules');

autodiscover(
  folder,
  { handler: 'function', name: 'string' }
).then((modules) => {
    // do something
});

The library will give you all the modules in the modules/ directory that matches the following export signature:

{
 name: string,
 handler: function
}