require-all
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -7,2 +7,6 @@ # Changes | ||
## v2.2.0 (2017-02-18) | ||
* Accept "filter" RegExps without any capture groups #43 #46 | ||
## v2.1.0 (2016-12-09) | ||
@@ -9,0 +13,0 @@ |
@@ -29,3 +29,3 @@ var fs = require('fs'); | ||
return match[1]; | ||
return match[1] || match[0]; | ||
} | ||
@@ -32,0 +32,0 @@ |
{ | ||
"name": "require-all", | ||
"description": "An easy way to require all files within a directory.", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -26,3 +26,4 @@ # require-all | ||
If your objective is to simply require all .js and .json files in a directory you can just pass a string to require-all: | ||
If your objective is to simply require all .js and .json files in a directory | ||
you can just pass a string to require-all: | ||
@@ -35,3 +36,4 @@ ``` js | ||
If your directory contains files that all export constructors, you can require them all and automatically construct the objects using `resolve`: | ||
If your directory contains files that all export constructors, you can require | ||
them all and automatically construct the objects using `resolve`: | ||
@@ -50,3 +52,6 @@ ```js | ||
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. | ||
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. | ||
@@ -67,3 +72,11 @@ ```js | ||
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 "Conroller.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 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. | ||
@@ -77,3 +90,6 @@ ```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. | ||
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. | ||
@@ -80,0 +96,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8243
108