# node-require-dir

> Powered require directory module, allowing recurse and filtering

Latest version **0.0.6** (published 2015-08-10) · 0 weekly downloads

## Install

```sh
npm install node-require-dir
pnpm add node-require-dir
yarn add node-require-dir
bun add node-require-dir
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2015-08-10 |
| First published | 2013-11-18 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | jon49, jviotti |

## Links

- npm: https://www.npmjs.com/package/node-require-dir
- npm.io page: https://npm.io/package/node-require-dir

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^3.8.0
- [fs-plus](https://npm.io/package/fs-plus.md) ~0.9.0

## Recent versions

- 0.0.6 (latest) — 2015-08-10
- 0.0.5 — 2015-06-24
- 0.0.4 — 2015-05-12
- 0.0.3 — 2013-11-18
- 0.0.1 — 2013-11-18
- 0.0.0 — 2013-11-18

## README

# node-require-dir

[![Build Status](https://secure.travis-ci.org/jviotti/node-require-dir.png?branch=master)](http://travis-ci.org/jviotti/node-require-dir)

## Alternatives

After taking over this project I discovered
[`require-glob`](https://www.npmjs.com/package/require-glob).

It is recommended to use the above project. If you find any similar projects
let me know and I'll add them.

## Installation

Install with npm:

```
npm install --save node-require-dir
```

## Example

```
var requiredir = require('node-require-dir');

var path = require('path');

var directory = requiredir(path.join(__dirname, 'directory'), function(name, module) {
  // Ommit json files
  if(path.extname(name) === '.json') return false;

  // Remove extension and append Controller
  return path.basename(name, path.extname(name)) + 'Controller';

  // Recursive
}, true);

console.log(directory);
// { firstController: {...}, otherControllers: { secondController: {...} }}

```

## API

### requiredir()

```
var result = requiredir(directoryName, namePredicate, recursive);
```

- **directoryName**: A string containing the name of the directory you want to
    include.
- **namePredicate**: (optional: identity) A function that ommits a module if it
    returns false. It also lets you modify the module name as presented in the example.
- **recursive**: (optional: false) Whether to recursively recurse the contents
    of the directory;

note that this function is not polymorphic, if you don't want to use a `predicate` but want to use
`recursive` you must pass an argument, like `null` or `_.identity`.

## Testing

From the repo root:

```
npm install
npm test
```

## Credits

This module was originally created and maintained by [Juan Cruz Viotti](https://www.npmjs.com/~jviotti).

---
_Source: https://npm.io/package/node-require-dir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
