require-plus

better require for directories

Usage no npm install needed!

<script type="module">
  import requirePlus from 'https://cdn.skypack.dev/require-plus';
</script>

README

require-plus

build status Current Version dependency Status devDependency Status Coveralls

Node module for requiring a directory tree, it will throw if not a valid directory and it will also throw if the object is not exported properly or cannot be required by require.

Installation

npm install require-plus

Usage

const options = {
    blacklist: ['node_modules', '.git', '.idea'],
    extensions: ['.js','.json'],
    directory: ['./test', './some/path', './some/other/path'] // can be a string or an array
};

const plus = require('require-plus')(options);
console.log(plus);
//plus is an object containing modules exported from above directories

Todo

  • 100% code coverage
  • Handle require errors better
  • Add silent error handling option to not throw if something cannot be required by require