{"name":"require-dir","description":"Helper to require() directories.","version":"0.2.0","author":{"name":"Aseem Kishore","email":"aseem.kishore@gmail.com"},"license":"MIT","dependencies":{},"devDependencies":{"coffee-script":"~1.3.3","mkdirp":"^0.5.0"},"engines":{"node":"*"},"scripts":{"test":"node test"},"homepage":"https://github.com/aseemk/requireDir","repository":{"type":"git","url":"git://github.com/aseemk/requireDir.git"},"gitHead":"e7499e888be68275556076d987bc9a57098bbfb3","bugs":{"url":"https://github.com/aseemk/requireDir/issues"},"_id":"require-dir@0.2.0","_shasum":"4f89d3a2edae22f20dedca6cadae38c8e5f59d33","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"aseemk","email":"aseem.kishore@gmail.com"},"maintainers":[{"name":"aseemk","email":"aseem.kishore@gmail.com"}],"dist":{"shasum":"4f89d3a2edae22f20dedca6cadae38c8e5f59d33","tarball":"http://registry-npm.ywwl.com/require-dir/download/require-dir-0.2.0.tgz","integrity":"sha512-T9G6xIBLj6eZdvSTtDx9RskSuiy/b6LEZq1DuBPngFTiXynt3G3OwKZD+ba0X//YEQxF+WtGiziMbKQEkWwkoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGSfwtaTNjLVIfxg2nQd81SY/tevB4uR+fEWcyH438pSAiEAmO44js0l0n0JWoA6F8ob5RlURLd7OdLjQxsQSKTS9DE="}],"size":5192,"noattachment":false,"key":"/require-dir/-/require-dir-0.2.0.tgz"},"directories":{},"readme":"[![Build Status](https://travis-ci.org/aseemk/requireDir.svg?branch=master)](https://travis-ci.org/aseemk/requireDir)\n[![npm version](https://badge.fury.io/js/require-dir.svg)](http://badge.fury.io/js/require-dir)\n\n# requireDir()\n\nNode helper to `require()` directories. The directory's files are examined,\nand each one that can be `require()`'d is `require()`'d and returned as part\nof a hash from that file's basename to its exported contents.\n\n## Example\n\nGiven this directory structure:\n\n```\ndir\n+ a.js\n+ b.json\n+ c.coffee\n+ d.txt\n```\n\n`requireDir('./dir')` will return the equivalent of:\n\n```js\n{\n  a: require('./dir/a.js'),\n  b: require('./dir/b.json')\n}\n```\n\nIf CoffeeScript is registered via `require('coffee-script/register')`,\n`c.coffee` will also be returned. Any extension registered with node will work the same way without any additional configuration.\n\n## Installation\n\n```\nnpm install require-dir\n```\n\nNote that this package is *not* `requireDir` — turns out that's already\n[taken](https://github.com/JamesEggers1/node-requiredir)! ;)\n\n## Usage\n\nBasic usage that examines only directories' immediate files:\n\n```js\nvar requireDir = require('require-dir');\nvar dir = requireDir('./path/to/dir');\n```\n\nYou can optionally customize the behavior by passing an extra options object:\n\n```js\nvar dir = requireDir('./path/to/dir', { recurse: true });\n```\n\n## Options\n\n`recurse`: Whether to recursively `require()` subdirectories too.\n(`node_modules` within subdirectories will be ignored.)\nDefault is false.\n\n`filter`: Apply a filter on the filename before require-ing. For example, ignoring files prefixed with `dev` in a production environment:\n\n```js\nrequireDir('./dir', {\n  filter: function (fullPath) {\n    return process.env.NODE_ENV !== 'production' && !fullPath.match(/$dev/);\n  }\n})\n```\n\n`mapKey`: Apply a transform to the module base name after require-ing. For example, uppercasing any module names:\n\n```js\nrequireDir('./dir', {\n  mapKey: function (value, baseName) {\n    return baseName.toUpperCase();\n  }\n})\n```\n\n`mapValue`: Apply a transform to the value after require-ing. For example, uppercasing any text exported:\n\n```js\nrequireDir('./dir', {\n  mapValue: function (value, baseName) {\n    return typeof value === 'string' ? value.toUpperCase() : value;\n  }\n})\n```\n\n`duplicates`: By default, if multiple files share the same basename, only the\nhighest priority one is `require()`'d and returned. (Priority is determined by\nthe order of `require.extensions` keys, with directories taking precedence\nover files if `recurse` is true.) Specifying this option `require()`'s all\nfiles and returns full filename keys in addition to basename keys.\nDefault is false.\n\nIn the example above, if there were also an `a.json`, the behavior would\nbe the same by default, but specifying `duplicates: true` would yield:\n\n```js\n{\n  a: require('./dir/a.js'),\n  'a.js': require('./dir/a.js'),\n  'a.json': require('./dir/a.json'),\n  b: require('./dir/b.json'),\n  'b.json': require('./dir/b.json')\n}\n```\n\n`noCache`: Prevent file caching. Could be useful using gulp.watch or other watch requiring refreshed file content Default is false.\n\n```js\nrequireDir('./dir', { noCache: true })\n```\n\n`extensions`: Array of extensions to look for instead of using `require.extensions`.\n\n```js\nrequireDir('./dir', { extensions: ['.js', '.json'] })\n```\n\n## Tips\n\nMake an `index.js` in a directory with this code to clean things up:\n\n```js\nmodule.exports = require('require-dir')();   // defaults to '.'\n```\n\nAnd don't worry, the calling file is always ignored to prevent infinite loops.\n","publish_time":1426858865171,"_cnpm_publish_time":1426858865171,"dist-tags":{"latest":"1.2.0"}}