ya-require-dir

A helper to require one directory

Usage no npm install needed!

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

README

ya-require-dir

Build Status npm version

Super simple to use

A helper to require() one directory recursively with no configuration params.

Installation

npm install ya-require-dir

Usage

There is only one param(default: '.') you would concern: the directory path.

let requireDir = require("ya-require-dir");
let dir = requireDir("./somewhere");

Given this directory structure:

dir
+ a.js
+ b.json
+ c
  +c-1.js
  +.dumb.js
+ d.txt

requireDir('./dir') will return the equivalent of:

{
  a: require('./dir/a.js'),
  b: require('./dir/b.json'),
  c: {
    c-1: require('./dir/c/c-1.js')
  }
}