Skip to content

Latest commit

 

History

History
77 lines (51 loc) · 1.94 KB

.verb.md

File metadata and controls

77 lines (51 loc) · 1.94 KB

{%= name %} {%= badge("travis") %} {%= badge("fury") %}

{%= description %}

This was ported from [export-files], use that project if you only want to export a directory of JavaScript files and you want the fastest possible way to do it besides defining each file explicitly.

{%= include("install-npm", {save: true}) %}

Usage

Specify the directory with files to export (this is a required argument):

module.exports = require('export-files')(__dirname);
//=> {a: [function], b: [function], c: [function]}

Params

module.exports = require('export-files')(dir, patterns, recurse, options, fn);
  • dir {String}: (required) directory with files to export.
  • patterns {String|Array|RegExp}: (optional) glob patterns or regex for filtering files
  • recurse {Boolean|Object}: (optional) or options. When true reads directories recursivly. Default is false.
  • options {Object}: (optional) options for filtering, reading, and recursion.
    • read {Function}: function for reading or requiring files
    • renameKey {Function}: function for naming keys on the returned object
    • filter {Function}: function for filtering files
  • fn {Function}: (optional) pass a custom reader function.

Examples

glob patterns

Filter and require only .json files:

module.exports = require('export-files')(__dirname, '**/*.json');

Filter and require only .yml files, with a custom

module.exports = require('export-files')(__dirname, '**/*.json');

Regex

Filter and require only .js files:

module.exports = require('export-files')(__dirname, /\.js$/);

Related

{%= related(['map-files', 'micromatch', 'file-reader']) %}

Run Tests

{%= include("tests") %}

Contributing

{%= include("contributing") %}

Author

{%= include("author") %}

License

{%= copyright({start: 2014}) %} {%= license() %}


{%= include("footer") %}

{%= reflinks(['export-files']) %}