4.0.0 • Published 7 years ago

require-glob-array v4.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

require-glob-array

require node modules and place their exported values in an array

npm Build Status Dependency Status

Usage

- dir
  - unicorn.js: module.exports = 'foo'
  - cake.js: module.exports = 'bar'
  - rainbow.js: module.exports = 'baz'
const requireGlobArray = require('require-glob-array')
let out = requireGlobArray({ cwd: 'dir' })
out //=> ['bar', 'baz', 'foo']

API

requireGlobArray(patterns, options)

Returns an array containing all of the exported values of the modules that are globbed.

Parameters:

  • patterns: string|array: minimatch patterns passed to globby. Defaults to **/*.js.
  • options: object: glob options passed to globby.
  • options.returnPath: Include the path in the return value. If true, instead of each export value, each item in the return array will now be [path, export], where:
    • path: The globbed path
    • export: The export value Default: undefined.

Returns:

  • Array: The exported modules.

requireGlobArray.async(patterns, options)

Run asynchronously. Has similar options to requireGlobArray (the synchronous version above).

The synchronous version is the default because it's probably what they'd want when they require a bunch of files.

Returns:

  • Promise<Array>: The exported modules.

NOT compatible with Browserify

Obviously, this module is not compatible with Browserify since it uses dynamic require calls.

License

MIT

4.0.0

7 years ago

3.0.0

8 years ago

2.1.3

8 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

1.0.0-1

8 years ago