first commit
This commit is contained in:
46
node_modules/require-all/Changes.md
generated
vendored
Normal file
46
node_modules/require-all/Changes.md
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Changes
|
||||
|
||||
This file is a manually maintained list of changes for each release. Feel free
|
||||
to add your changes here when sending pull requests. Also send corrections if
|
||||
you spot any mistakes.
|
||||
|
||||
## v3.0.0 (2018-07-02)
|
||||
|
||||
* Drop support for Node.js 0.6 and below #54 #56
|
||||
* Skip adding keys for directories without modules #51 #53
|
||||
|
||||
## v2.2.0 (2017-02-18)
|
||||
|
||||
* Accept "filter" RegExps without any capture groups #43 #46
|
||||
|
||||
## v2.1.0 (2016-12-09)
|
||||
|
||||
* Accept a function for "filter" option #27 #31
|
||||
|
||||
## v2.0.0 (2015-10-17)
|
||||
|
||||
* Add "recursive" argument to control directory recursion #21
|
||||
* Default "excludeDirs" and "filter" if not provided in options #19
|
||||
* Ignore dot files & folder by default #12
|
||||
* Update the "map" property to map directory names #20
|
||||
|
||||
## Older releases
|
||||
|
||||
These releases were done before maintaining this file:
|
||||
|
||||
* [v1.1.0](https://github.com/felixge/node-require-all/compare/v1.0.0...v1.1.0)
|
||||
(2015-05-19)
|
||||
* [v1.0.0](https://github.com/felixge/node-require-all/compare/v0.0.8...v1.0.0)
|
||||
(2014-12-01)
|
||||
* [v0.0.8](https://github.com/felixge/node-require-all/compare/v0.0.6...v0.0.8)
|
||||
(2013-08-19)
|
||||
* [v0.0.6](https://github.com/felixge/node-require-all/compare/v0.0.4...v0.0.6)
|
||||
(2013-03-13)
|
||||
* [v0.0.4](https://github.com/felixge/node-require-all/compare/v0.0.3...v0.0.4)
|
||||
(2012-06-12)
|
||||
* [v0.0.3](https://github.com/felixge/node-require-all/compare/v0.0.2...v0.0.3)
|
||||
(2012-01-12)
|
||||
* [v0.0.2](https://github.com/felixge/node-require-all/compare/v0.0.1...v0.0.2)
|
||||
(2011-12-19)
|
||||
* [v0.0.1](https://github.com/felixge/node-require-all/commits/v0.0.1)
|
||||
(2011-12-14)
|
||||
22
node_modules/require-all/LICENSE
generated
vendored
Normal file
22
node_modules/require-all/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
109
node_modules/require-all/Readme.md
generated
vendored
Normal file
109
node_modules/require-all/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# require-all
|
||||
|
||||
An easy way to require all files within a directory.
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var controllers = require('require-all')({
|
||||
dirname : __dirname + '/controllers',
|
||||
filter : /(.+Controller)\.js$/,
|
||||
excludeDirs : /^\.(git|svn)$/,
|
||||
recursive : true
|
||||
});
|
||||
|
||||
// controllers now is an object with references to all modules matching the filter
|
||||
// for example:
|
||||
// { HomeController: function HomeController() {...}, ...}
|
||||
```
|
||||
|
||||
## Advanced usage
|
||||
|
||||
If your objective is to simply require all .js and .json files in a directory
|
||||
you can just pass a string to require-all:
|
||||
|
||||
``` js
|
||||
var libs = require('require-all')(__dirname + '/lib');
|
||||
```
|
||||
|
||||
### Constructed object usage
|
||||
|
||||
If your directory contains files that all export constructors, you can require
|
||||
them all and automatically construct the objects using `resolve`:
|
||||
|
||||
```js
|
||||
var controllers = require('require-all')({
|
||||
dirname : __dirname + '/controllers',
|
||||
filter : /(.+Controller)\.js$/,
|
||||
resolve : function (Controller) {
|
||||
return new Controller();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Alternative property names
|
||||
|
||||
If your directory contains files where the names do not match what you want in
|
||||
the resulting property (for example, you want camelCase but the file names are
|
||||
snake_case), then you can use the `map` function. The `map` function is called
|
||||
on both file and directory names, as they are added to the resulting object.
|
||||
|
||||
```js
|
||||
var controllers = require('require-all')({
|
||||
dirname : __dirname + '/controllers',
|
||||
filter : /(.+Controller)\.js$/,
|
||||
map : function (name, path) {
|
||||
return name.replace(/_([a-z])/g, function (m, c) {
|
||||
return c.toUpperCase();
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Filtering files
|
||||
|
||||
If your directory contains files that you do not want to require, or that you
|
||||
want only a part of the file's name to be used as the property name, `filter`
|
||||
can be a regular expression. In the following example, the `filter` is set to
|
||||
`/^(.+Controller)\.js$/`, which means only files that end in "Controller.js"
|
||||
are required, and the resulting property name will be the name of the file
|
||||
without the ".js" extension. For example, the file "MainController.js" will
|
||||
match, and since the first capture group will contain "MainController", that
|
||||
will be the property name used. If no capture group is used, then the entire
|
||||
match will be used as the name.
|
||||
|
||||
```js
|
||||
var controllers = require('require-all')({
|
||||
dirname : __dirname + '/controllers',
|
||||
filter : /^(.+Controller)\.js$/
|
||||
});
|
||||
```
|
||||
|
||||
For even more advanced usage, the `filter` option also accepts a function that
|
||||
is invoked with the file name as the first argument. The filter function is
|
||||
expected to return a falsy value to ignore the file, otherwise a string to use
|
||||
as the property name.
|
||||
|
||||
```js
|
||||
var controllers = requireAll({
|
||||
dirname : __dirname + '/controllers',
|
||||
filter : function (fileName) {
|
||||
var parts = fileName.split('-');
|
||||
if (parts[1] !== 'Controller.js') return;
|
||||
return parts[0];
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Note that empty directories are always excluded from the end result.
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/require-all.svg
|
||||
[npm-url]: https://npmjs.org/package/require-all
|
||||
[downloads-image]: https://img.shields.io/npm/dm/require-all.svg
|
||||
[downloads-url]: https://npmjs.org/package/require-all
|
||||
[travis-image]: https://img.shields.io/travis/felixge/node-require-all/master.svg
|
||||
[travis-url]: https://travis-ci.org/felixge/node-require-all
|
||||
65
node_modules/require-all/index.js
generated
vendored
Normal file
65
node_modules/require-all/index.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
var fs = require('fs');
|
||||
|
||||
var DEFAULT_EXCLUDE_DIR = /^\./;
|
||||
var DEFAULT_FILTER = /^([^\.].*)\.js(on)?$/;
|
||||
var DEFAULT_RECURSIVE = true;
|
||||
|
||||
module.exports = function requireAll(options) {
|
||||
var dirname = typeof options === 'string' ? options : options.dirname;
|
||||
var excludeDirs = options.excludeDirs === undefined ? DEFAULT_EXCLUDE_DIR : options.excludeDirs;
|
||||
var filter = options.filter === undefined ? DEFAULT_FILTER : options.filter;
|
||||
var modules = {};
|
||||
var recursive = options.recursive === undefined ? DEFAULT_RECURSIVE : options.recursive;
|
||||
var resolve = options.resolve || identity;
|
||||
var map = options.map || identity;
|
||||
|
||||
function excludeDirectory(dirname) {
|
||||
return !recursive ||
|
||||
(excludeDirs && dirname.match(excludeDirs));
|
||||
}
|
||||
|
||||
function filterFile(filename) {
|
||||
if (typeof filter === 'function') {
|
||||
return filter(filename);
|
||||
}
|
||||
|
||||
var match = filename.match(filter);
|
||||
if (!match) return;
|
||||
|
||||
return match[1] || match[0];
|
||||
}
|
||||
|
||||
var files = fs.readdirSync(dirname);
|
||||
|
||||
files.forEach(function (file) {
|
||||
var filepath = dirname + '/' + file;
|
||||
if (fs.statSync(filepath).isDirectory()) {
|
||||
|
||||
if (excludeDirectory(file)) return;
|
||||
|
||||
var subModules = requireAll({
|
||||
dirname: filepath,
|
||||
filter: filter,
|
||||
excludeDirs: excludeDirs,
|
||||
map: map,
|
||||
resolve: resolve
|
||||
});
|
||||
|
||||
if (Object.keys(subModules).length === 0) return;
|
||||
|
||||
modules[map(file, filepath)] = subModules;
|
||||
|
||||
} else {
|
||||
var name = filterFile(file);
|
||||
if (!name) return;
|
||||
|
||||
modules[map(name, filepath)] = resolve(require(filepath));
|
||||
}
|
||||
});
|
||||
|
||||
return modules;
|
||||
};
|
||||
|
||||
function identity(val) {
|
||||
return val;
|
||||
}
|
||||
25
node_modules/require-all/package.json
generated
vendored
Normal file
25
node_modules/require-all/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "require-all",
|
||||
"description": "An easy way to require all files within a directory.",
|
||||
"version": "3.0.0",
|
||||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Prince Obiechine Onyenike <leewaygroups@gmail.com>",
|
||||
"Nuno Job <nunojobpinto@gmail.com> (http://nunojob.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "felixge/node-require-all",
|
||||
"files": [
|
||||
"Changes.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"Readme.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user