package.json 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. {
  2. "_args": [
  3. [
  4. {
  5. "raw": "require-directory@^2.1.1",
  6. "scope": null,
  7. "escapedName": "require-directory",
  8. "name": "require-directory",
  9. "rawSpec": "^2.1.1",
  10. "spec": ">=2.1.1 <3.0.0",
  11. "type": "range"
  12. },
  13. "/mnt/Data/bach/Documents/ola/OLA#4/OLA#4DOC/sys/node_modules/yargs"
  14. ]
  15. ],
  16. "_from": "require-directory@>=2.1.1 <3.0.0",
  17. "_id": "require-directory@2.1.1",
  18. "_inCache": true,
  19. "_location": "/require-directory",
  20. "_nodeVersion": "0.12.0",
  21. "_npmUser": {
  22. "name": "troygoode",
  23. "email": "troygoode@gmail.com"
  24. },
  25. "_npmVersion": "2.5.1",
  26. "_phantomChildren": {},
  27. "_requested": {
  28. "raw": "require-directory@^2.1.1",
  29. "scope": null,
  30. "escapedName": "require-directory",
  31. "name": "require-directory",
  32. "rawSpec": "^2.1.1",
  33. "spec": ">=2.1.1 <3.0.0",
  34. "type": "range"
  35. },
  36. "_requiredBy": [
  37. "/yargs"
  38. ],
  39. "_resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
  40. "_shasum": "8c64ad5fd30dab1c976e2344ffe7f792a6a6df42",
  41. "_shrinkwrap": null,
  42. "_spec": "require-directory@^2.1.1",
  43. "_where": "/mnt/Data/bach/Documents/ola/OLA#4/OLA#4DOC/sys/node_modules/yargs",
  44. "author": {
  45. "name": "Troy Goode",
  46. "email": "troygoode@gmail.com",
  47. "url": "http://github.com/troygoode/"
  48. },
  49. "bugs": {
  50. "url": "http://github.com/troygoode/node-require-directory/issues/"
  51. },
  52. "contributors": [
  53. {
  54. "name": "Troy Goode",
  55. "email": "troygoode@gmail.com",
  56. "url": "http://github.com/troygoode/"
  57. }
  58. ],
  59. "dependencies": {},
  60. "description": "Recursively iterates over specified directory, require()'ing each file, and returning a nested hash structure containing those modules.",
  61. "devDependencies": {
  62. "jshint": "^2.6.0",
  63. "mocha": "^2.1.0"
  64. },
  65. "directories": {},
  66. "dist": {
  67. "shasum": "8c64ad5fd30dab1c976e2344ffe7f792a6a6df42",
  68. "tarball": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz"
  69. },
  70. "engines": {
  71. "node": ">=0.10.0"
  72. },
  73. "gitHead": "cc71c23dd0c16cefd26855303c16ca1b9b50a36d",
  74. "homepage": "https://github.com/troygoode/node-require-directory/",
  75. "keywords": [
  76. "require",
  77. "directory",
  78. "library",
  79. "recursive"
  80. ],
  81. "license": "MIT",
  82. "main": "index.js",
  83. "maintainers": [
  84. {
  85. "name": "troygoode",
  86. "email": "troygoode@gmail.com"
  87. }
  88. ],
  89. "name": "require-directory",
  90. "optionalDependencies": {},
  91. "readme": "# require-directory\n\nRecursively iterates over specified directory, `require()`'ing each file, and returning a nested hash structure containing those modules.\n\n**[Follow me (@troygoode) on Twitter!](https://twitter.com/intent/user?screen_name=troygoode)**\n\n[![NPM](https://nodei.co/npm/require-directory.png?downloads=true&stars=true)](https://nodei.co/npm/require-directory/)\n\n[![build status](https://secure.travis-ci.org/troygoode/node-require-directory.png)](http://travis-ci.org/troygoode/node-require-directory)\n\n## How To Use\n\n### Installation (via [npm](https://npmjs.org/package/require-directory))\n\n```bash\n$ npm install require-directory\n```\n\n### Usage\n\nA common pattern in node.js is to include an index file which creates a hash of the files in its current directory. Given a directory structure like so:\n\n* app.js\n* routes/\n * index.js\n * home.js\n * auth/\n * login.js\n * logout.js\n * register.js\n\n`routes/index.js` uses `require-directory` to build the hash (rather than doing so manually) like so:\n\n```javascript\nvar requireDirectory = require('require-directory');\nmodule.exports = requireDirectory(module);\n```\n\n`app.js` references `routes/index.js` like any other module, but it now has a hash/tree of the exports from the `./routes/` directory:\n\n```javascript\nvar routes = require('./routes');\n\n// snip\n\napp.get('/', routes.home);\napp.get('/register', routes.auth.register);\napp.get('/login', routes.auth.login);\napp.get('/logout', routes.auth.logout);\n```\n\nThe `routes` variable above is the equivalent of this:\n\n```javascript\nvar routes = {\n home: require('routes/home.js'),\n auth: {\n login: require('routes/auth/login.js'),\n logout: require('routes/auth/logout.js'),\n register: require('routes/auth/register.js')\n }\n};\n```\n\n*Note that `routes.index` will be `undefined` as you would hope.*\n\n### Specifying Another Directory\n\nYou can specify which directory you want to build a tree of (if it isn't the current directory for whatever reason) by passing it as the second parameter. Not specifying the path (`requireDirectory(module)`) is the equivelant of `requireDirectory(module, __dirname)`:\n\n```javascript\nvar requireDirectory = require('require-directory');\nmodule.exports = requireDirectory(module, './some/subdirectory');\n```\n\nFor example, in the [example in the Usage section](#usage) we could have avoided creating `routes/index.js` and instead changed the first lines of `app.js` to:\n\n```javascript\nvar requireDirectory = require('require-directory');\nvar routes = requireDirectory(module, './routes');\n```\n\n## Options\n\nYou can pass an options hash to `require-directory` as the 2nd parameter (or 3rd if you're passing the path to another directory as the 2nd parameter already). Here are the available options:\n\n### Whitelisting\n\nWhitelisting (either via RegExp or function) allows you to specify that only certain files be loaded.\n\n```javascript\nvar requireDirectory = require('require-directory'),\n whitelist = /onlyinclude.js$/,\n hash = requireDirectory(module, {include: whitelist});\n```\n\n```javascript\nvar requireDirectory = require('require-directory'),\n check = function(path){\n if(/onlyinclude.js$/.test(path)){\n return true; // don't include\n }else{\n return false; // go ahead and include\n }\n },\n hash = requireDirectory(module, {include: check});\n```\n\n### Blacklisting\n\nBlacklisting (either via RegExp or function) allows you to specify that all but certain files should be loaded.\n\n```javascript\nvar requireDirectory = require('require-directory'),\n blacklist = /dontinclude\\.js$/,\n hash = requireDirectory(module, {exclude: blacklist});\n```\n\n```javascript\nvar requireDirectory = require('require-directory'),\n check = function(path){\n if(/dontinclude\\.js$/.test(path)){\n return false; // don't include\n }else{\n return true; // go ahead and include\n }\n },\n hash = requireDirectory(module, {exclude: check});\n```\n\n### Visiting Objects As They're Loaded\n\n`require-directory` takes a function as the `visit` option that will be called for each module that is added to module.exports.\n\n```javascript\nvar requireDirectory = require('require-directory'),\n visitor = function(obj) {\n console.log(obj); // will be called for every module that is loaded\n },\n hash = requireDirectory(module, {visit: visitor});\n```\n\nThe visitor can also transform the objects by returning a value:\n\n```javascript\nvar requireDirectory = require('require-directory'),\n visitor = function(obj) {\n return obj(new Date());\n },\n hash = requireDirectory(module, {visit: visitor});\n```\n\n### Renaming Keys\n\n```javascript\nvar requireDirectory = require('require-directory'),\n renamer = function(name) {\n return name.toUpperCase();\n },\n hash = requireDirectory(module, {rename: renamer});\n```\n\n### No Recursion\n\n```javascript\nvar requireDirectory = require('require-directory'),\n hash = requireDirectory(module, {recurse: false});\n```\n\n## Run Unit Tests\n\n```bash\n$ npm run lint\n$ npm test\n```\n\n## License\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\n## Author\n\n[Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com))\n\n",
  92. "readmeFilename": "README.markdown",
  93. "repository": {
  94. "type": "git",
  95. "url": "git://github.com/troygoode/node-require-directory.git"
  96. },
  97. "scripts": {
  98. "lint": "jshint index.js test/test.js",
  99. "test": "mocha"
  100. },
  101. "version": "2.1.1"
  102. }