1.0.0 • Published 8 years ago

require-hapi-plugin-dir v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

require-hapi-plugin-dir

Build Status

A simple method of requiring all files in a directory, but specifically for hapi plugins that don't require options.

Use:

Directory Structure

MyPlugins/
    |- index.js
    |- myplugin1.js
    |- myplugin2.js
    |- myplugin3.js

index.js

module.exports = require('require-hapi-plugin-dir')(module);

This package simply exports each plugin in a flat array. Given the example directory structure above, this array would be equivalent to:

module.exports = [
    require('./myplugin1'),
    require('./myplugin2'),
    require('./myplugin3')
];

See the "load multiple plugins" example under Loading a Plugin for more info.


Alternate directory structure

MyPlugins/
    |- index.js
    |- myplugin1.js
    |- myplugin2.js
    |- myplugin3.js
    |- MyOtherPlugins/
        |- index.js
        |- mypluginA.js
        |- mypluginB.js
        |- mypluginC.js

Which would present as:

module.exports = [
    require('./mypluginA'),
    require('./mypluginB'),
    require('./mypluginC'),
    require('./myplugin1'),
    require('./myplugin2'),
    require('./myplugin3')
];

API

reqHapiPluginDir(module[, options]);

module

Node's module object contains a property named filename, thus it is important to pass this object from the index.js file which is being called.

options

optional options (haha!) object.

  • include - An array of hapi plugins to include manually.
  • flat - If set to true, the above directory structure would only include files from MyPlugins and completely ignore the MyOtherPlugins directory. Default: false.
1.0.0

8 years ago

0.3.0

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago