1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-01 16:51:13 -05:00
denoland-deno/tests/registry/npm/require-directory/registry.json

2 lines
7.1 KiB
JSON
Raw Normal View History

{"name":"require-directory","description":"Recursively iterates over specified directory, require()'ing each file, and returning a nested hash structure containing those modules.","dist-tags":{"latest":"2.1.1"},"versions":{"2.1.1":{"author":{"name":"Troy Goode","email":"troygoode@gmail.com","url":"http://github.com/troygoode/"},"name":"require-directory","version":"2.1.1","description":"Recursively iterates over specified directory, require()'ing each file, and returning a nested hash structure containing those modules.","main":"index.js","repository":{"type":"git","url":"git://github.com/troygoode/node-require-directory.git"},"license":"MIT","bugs":{"url":"http://github.com/troygoode/node-require-directory/issues/"},"engines":{"node":">=0.10.0"},"devDependencies":{"jshint":"^2.6.0","mocha":"^2.1.0"},"scripts":{"test":"mocha","lint":"jshint index.js test/test.js"},"gitHead":"cc71c23dd0c16cefd26855303c16ca1b9b50a36d","_id":"require-directory@2.1.1","_shasum":"8c64ad5fd30dab1c976e2344ffe7f792a6a6df42","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","dist":{"shasum":"8c64ad5fd30dab1c976e2344ffe7f792a6a6df42","tarball":"http://localhost:4260/require-directory/require-directory-2.1.1.tgz","integrity":"sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGClBqRURzZkkK060ZZVZeHq85UyQvNt6ZF9KOQfN12PAiABryiFbUkYd99blPQeu55J/QCLQFAzUicy/mm6OR5I9g=="}]},"directories":{}}},"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 = requi