diff -Nru node-require-all-0.0.6/Changes.md node-require-all-3.0.0/Changes.md --- node-require-all-0.0.6/Changes.md 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/Changes.md 2018-07-03 04:43:32.000000000 +0000 @@ -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) diff -Nru node-require-all-0.0.6/debian/changelog node-require-all-3.0.0/debian/changelog --- node-require-all-0.0.6/debian/changelog 2013-05-15 21:17:41.000000000 +0000 +++ node-require-all-3.0.0/debian/changelog 2019-01-23 10:45:27.000000000 +0000 @@ -1,3 +1,21 @@ +node-require-all (3.0.0-1) unstable; urgency=medium + + * Team upload + * New upstream version 3.0.0 + * Add upstream/metadata + * Install missing package.json + * Enable upstream test during build + * Add nodejs in build dependencies + * Bump debhelper compatibility level to 11 + * Change section to javascript + * Declare compliance with policy 4.3.0 + * Change priority to optional + * Update VCS fields to salsa + * Update debian/copyright format link + * Add autopkgtest files + + -- Xavier Guimard Wed, 23 Jan 2019 11:45:27 +0100 + node-require-all (0.0.6-1) unstable; urgency=low * Initial release. (Closes: #708326). diff -Nru node-require-all-0.0.6/debian/compat node-require-all-3.0.0/debian/compat --- node-require-all-0.0.6/debian/compat 2013-05-07 09:09:42.000000000 +0000 +++ node-require-all-3.0.0/debian/compat 2019-01-23 10:38:53.000000000 +0000 @@ -1 +1 @@ -8 +11 diff -Nru node-require-all-0.0.6/debian/control node-require-all-3.0.0/debian/control --- node-require-all-0.0.6/debian/control 2013-05-15 21:15:55.000000000 +0000 +++ node-require-all-3.0.0/debian/control 2019-01-23 10:38:53.000000000 +0000 @@ -1,22 +1,19 @@ Source: node-require-all -Section: web -Priority: extra Maintainer: Debian Javascript Maintainers -Uploaders: - Mike Gabriel , -Build-Depends: - debhelper (>= 8.0.0), - dh-buildinfo, -Standards-Version: 3.9.4 +Uploaders: Mike Gabriel +Section: javascript +Priority: optional +Build-Depends: debhelper (>= 11~), + nodejs +Standards-Version: 4.3.0 +Vcs-Browser: https://salsa.debian.org/js-team/node-require-all +Vcs-Git: https://salsa.debian.org/js-team/node-require-all.git Homepage: https://github.com/felixge/node-require-all -Vcs-Git: git://git.debian.org/collab-maint/node-require-all.git -Vcs-Browser: http://git.debian.org/?p=collab-maint/node-require-all.git Package: node-require-all Architecture: all -Depends: - ${misc:Depends}, - nodejs (>= 0.6.19~dfsg1-3~), +Depends: ${misc:Depends}, + nodejs Description: Require all Node.js module files within a directory This Node.js module provides an easy way to require all module files within a directory. diff -Nru node-require-all-0.0.6/debian/copyright node-require-all-3.0.0/debian/copyright --- node-require-all-0.0.6/debian/copyright 2013-05-15 06:19:15.000000000 +0000 +++ node-require-all-3.0.0/debian/copyright 2019-01-23 10:38:53.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: node-require-all Upstream-Contact: Felix Geisendörfer Source: https://github.com/felixge/node-require-all diff -Nru node-require-all-0.0.6/debian/install node-require-all-3.0.0/debian/install --- node-require-all-0.0.6/debian/install 2013-05-15 07:14:13.000000000 +0000 +++ node-require-all-3.0.0/debian/install 2019-01-23 10:33:10.000000000 +0000 @@ -1 +1,2 @@ -*.js usr/lib/nodejs/require-all/ +index.js usr/lib/nodejs/require-all/ +package.json usr/lib/nodejs/require-all/ diff -Nru node-require-all-0.0.6/debian/rules node-require-all-3.0.0/debian/rules --- node-require-all-0.0.6/debian/rules 2013-05-15 21:16:47.000000000 +0000 +++ node-require-all-3.0.0/debian/rules 2019-01-23 10:38:53.000000000 +0000 @@ -6,3 +6,8 @@ %: dh $@ + +override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + node test/test.js +endif diff -Nru node-require-all-0.0.6/debian/tests/control node-require-all-3.0.0/debian/tests/control --- node-require-all-0.0.6/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/debian/tests/control 2019-01-23 10:40:41.000000000 +0000 @@ -0,0 +1,5 @@ +Test-Command: nodejs -e "require('require-all');" +Depends: @ + +Tests: upstream +Depends: @, @builddeps@ diff -Nru node-require-all-0.0.6/debian/tests/upstream node-require-all-3.0.0/debian/tests/upstream --- node-require-all-0.0.6/debian/tests/upstream 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/debian/tests/upstream 2019-01-23 10:40:47.000000000 +0000 @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +TEMP=${ADTTMP:-${TMPDIR:-/tmp}} +TDIR=$(mktemp -d $TEMP/smokeXXXXXX) +PDIR=`pwd` + +cp -a test $TDIR/ +cd $TDIR +ln -s /usr/lib/nodejs/require-all/package.json +ln -s /usr/lib/nodejs/require-all/index.js +node test/test.js diff -Nru node-require-all-0.0.6/debian/upstream/metadata node-require-all-3.0.0/debian/upstream/metadata --- node-require-all-0.0.6/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/debian/upstream/metadata 2019-01-23 10:34:07.000000000 +0000 @@ -0,0 +1,7 @@ +--- +Archive: GitHub +Bug-Database: https://github.com/felixge/node-require-all/issues +Contact: https://github.com/felixge/node-require-all/issues +Name: node-require-all +Repository: https://github.com/felixge/node-require-all.git +Repository-Browse: https://github.com/felixge/node-require-all diff -Nru node-require-all-0.0.6/.gitignore node-require-all-3.0.0/.gitignore --- node-require-all-0.0.6/.gitignore 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/.gitignore 2018-07-03 04:43:32.000000000 +0000 @@ -1 +1,3 @@ *.un~ +node_modules/ +package-lock.json diff -Nru node-require-all-0.0.6/index.js node-require-all-3.0.0/index.js --- node-require-all-0.0.6/index.js 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/index.js 2018-07-03 04:43:32.000000000 +0000 @@ -1,33 +1,65 @@ -var fs = require('fs'); +var fs = require('fs'); + +var DEFAULT_EXCLUDE_DIR = /^\./; +var DEFAULT_FILTER = /^([^\.].*)\.js(on)?$/; +var DEFAULT_RECURSIVE = true; module.exports = function requireAll(options) { - var files = fs.readdirSync(options.dirname); + 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 options.excludeDirs && dirname.match(options.excludeDirs); + return !recursive || + (excludeDirs && dirname.match(excludeDirs)); } - files.forEach(function(file) { - var filepath = options.dirname + '/' + file; + 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; - modules[file] = requireAll({ - dirname : filepath, - filter : options.filter, - excludeDirs : options.excludeDirs + 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 match = file.match(options.filter); - if (!match) return; + var name = filterFile(file); + if (!name) return; - modules[match[1]] = require(filepath); + modules[map(name, filepath)] = resolve(require(filepath)); } }); return modules; }; +function identity(val) { + return val; +} diff -Nru node-require-all-0.0.6/License node-require-all-3.0.0/License --- node-require-all-0.0.6/License 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/License 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors - - 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. \ No newline at end of file diff -Nru node-require-all-0.0.6/LICENSE node-require-all-3.0.0/LICENSE --- node-require-all-0.0.6/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/LICENSE 2018-07-03 04:43:32.000000000 +0000 @@ -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. diff -Nru node-require-all-0.0.6/package.json node-require-all-3.0.0/package.json --- node-require-all-0.0.6/package.json 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/package.json 2018-07-03 04:43:32.000000000 +0000 @@ -1,26 +1,25 @@ { - "author": "Felix Geisendörfer (http://debuggable.com/)", "name": "require-all", "description": "An easy way to require all files within a directory.", - "version": "0.0.6", - "scripts": { - "test": "node test/test.js" - }, - "repository": { - "type": "git", - "url": "git://github.com/felixge/node-require-all.git" - }, - "licenses": [ - { - "type": "MIT", - "url": "https://github.com/felixge/node-require-all/blob/master/License" - } + "version": "3.0.0", + "author": "Felix Geisendörfer (http://debuggable.com/)", + "contributors": [ + "Douglas Christopher Wilson ", + "Prince Obiechine Onyenike ", + "Nuno Job (http://nunojob.com)" + ], + "license": "MIT", + "repository": "felixge/node-require-all", + "files": [ + "Changes.md", + "LICENSE", + "index.js", + "Readme.md" ], - "main": "./index", "engines": { - "node": "*" + "node": ">= 0.8" }, - "dependencies": {}, - "devDependencies": {}, - "optionalDependencies": {} + "scripts": { + "test": "node test/test.js" + } } diff -Nru node-require-all-0.0.6/Readme.md node-require-all-3.0.0/Readme.md --- node-require-all-0.0.6/Readme.md 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/Readme.md 2018-07-03 04:43:32.000000000 +0000 @@ -2,16 +2,108 @@ 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)$/ + 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 diff -Nru node-require-all-0.0.6/test/controllers/.hidden/stuff.js node-require-all-3.0.0/test/controllers/.hidden/stuff.js --- node-require-all-0.0.6/test/controllers/.hidden/stuff.js 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/test/controllers/.hidden/stuff.js 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1 @@ +module.exports = { gute: 'nacht' }; diff -Nru node-require-all-0.0.6/test/controllers/sub-dir/other-Controller.js node-require-all-3.0.0/test/controllers/sub-dir/other-Controller.js --- node-require-all-0.0.6/test/controllers/sub-dir/other-Controller.js 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/test/controllers/sub-dir/other-Controller.js 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1,2 @@ +exports.index = 1; +exports.show = 2; diff -Nru node-require-all-0.0.6/test/mydir/.stuff.js node-require-all-3.0.0/test/mydir/.stuff.js --- node-require-all-0.0.6/test/mydir/.stuff.js 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/test/mydir/.stuff.js 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1 @@ +module.exports = { gute: 'nacht' }; diff -Nru node-require-all-0.0.6/test/resolved/onearg.js node-require-all-3.0.0/test/resolved/onearg.js --- node-require-all-0.0.6/test/resolved/onearg.js 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/test/resolved/onearg.js 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1,3 @@ +module.exports = function (arg1, arg2) { + return arg1; +} diff -Nru node-require-all-0.0.6/test/resolved/twoargs.js node-require-all-3.0.0/test/resolved/twoargs.js --- node-require-all-0.0.6/test/resolved/twoargs.js 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/test/resolved/twoargs.js 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1,3 @@ +module.exports = function (arg1, arg2) { + return arg2; +} diff -Nru node-require-all-0.0.6/test/test.js node-require-all-3.0.0/test/test.js --- node-require-all-0.0.6/test/test.js 2013-03-13 15:41:30.000000000 +0000 +++ node-require-all-3.0.0/test/test.js 2018-07-03 04:43:32.000000000 +0000 @@ -17,34 +17,187 @@ 'other-Controller': { index: 1, show: 'nothing' + }, + + 'sub-dir': { + 'other-Controller': { + index: 1, + show: 2 + } + } +}); + +var controllersTop = requireAll({ + dirname: __dirname + '/controllers', + filter: /(.+Controller)\.js$/, + recursive: false +}); + +assert.deepEqual(controllersTop, { + 'main-Controller': { + index: 1, + show: 2, + add: 3, + edit: 4 + }, + + 'other-Controller': { + index: 1, + show: 'nothing' + } +}); + +var controllersMap = requireAll({ + dirname: __dirname + '/controllers', + filter: /(.+Controller)\.js$/, + map: function (name) { + return name.replace(/-([A-Z])/, function (m, c) { + return '_' + c.toLowerCase(); + }); } }); +assert.deepEqual(controllersMap, { + main_controller: { + index: 1, + show: 2, + add: 3, + edit: 4 + }, -if (process.version > 'v0.6.0') { - var mydir = requireAll({ - dirname: __dirname + '/mydir', - filter: /(.+)\.(js|json)$/ - }); - - assert.deepEqual(mydir, { - foo: 'bar', - hello: { world: true, universe: 42 }, - sub: { - config: { settingA: 'A', settingB: 'B' }, - yes: true + other_controller: { + index: 1, + show: 'nothing' + }, + + 'sub-dir': { + other_controller: { + index: 1, + show: 2 } - }); -} + } +}); + +var controllersMap = requireAll({ + dirname: __dirname + '/controllers', + filter: /.+Controller\.js$/ +}); + +assert.deepEqual(controllersMap, { + 'main-Controller.js': { + index: 1, + show: 2, + add: 3, + edit: 4 + }, + 'other-Controller.js': { + index: 1, + show: 'nothing' + }, + 'sub-dir': { + 'other-Controller.js': { + index: 1, + show: 2 + } + } +}); + +controllersMap = requireAll({ + dirname: __dirname + '/controllers', + filter: /(.+Controller)\.js$/, + map: function (name) { + return name.replace(/-([A-Za-z])/, function (m, c) { + return '_' + c.toLowerCase(); + }); + } +}); + +assert.deepEqual(controllersMap, { + main_controller: { + index: 1, + show: 2, + add: 3, + edit: 4 + }, + + other_controller: { + index: 1, + show: 'nothing' + }, + + sub_dir: { + other_controller: { + index: 1, + show: 2 + } + } +}); + +controllersMap = requireAll({ + dirname: __dirname + '/controllers', + filter: /(.+Controller)\.js$/, + map: function (name) { + return name.replace(/-([A-Za-z])/, function (m, c) { + return '_' + c.toLowerCase(); + }); + } +}); + +assert.deepEqual(controllersMap, { + main_controller: { + index: 1, + show: 2, + add: 3, + edit: 4 + }, + + other_controller: { + index: 1, + show: 'nothing' + }, + + sub_dir: { + other_controller: { + index: 1, + show: 2 + } + } +}); + +var mydir = requireAll({ + dirname: __dirname + '/mydir' +}); + +var mydir_contents = { + foo: 'bar', + hello: { + world: true, + universe: 42 + }, + sub: { + config: { + settingA: 'A', + settingB: 'B' + }, + yes: true + } +}; + +assert.deepEqual(mydir, mydir_contents); + +var defaults = requireAll(__dirname + '/mydir'); + +assert.deepEqual(defaults, mydir_contents); var unfiltered = requireAll({ dirname: __dirname + '/filterdir', - filter: /(.+)\.js$/ + filter: /(.+)\.js$/, + excludeDirs: false }); assert(unfiltered['.svn']); -assert(unfiltered['root']); -assert(unfiltered['sub']); +assert(unfiltered.root); +assert(unfiltered.sub); var excludedSvn = requireAll({ dirname: __dirname + '/filterdir', @@ -53,8 +206,8 @@ }); assert.equal(excludedSvn['.svn'], undefined); -assert.ok(excludedSvn['root']); -assert.ok(excludedSvn['sub']); +assert.ok(excludedSvn.root); +assert.ok(excludedSvn.sub); var excludedSvnAndSub = requireAll({ dirname: __dirname + '/filterdir', @@ -63,5 +216,46 @@ }); assert.equal(excludedSvnAndSub['.svn'], undefined); -assert.ok(excludedSvnAndSub['root']); -assert.equal(excludedSvnAndSub['sub'], undefined); +assert.ok(excludedSvnAndSub.root); +assert.equal(excludedSvnAndSub.sub, undefined); + +var resolvedValues = requireAll({ + dirname: __dirname + '/resolved', + filter: /(.+)\.js$/, + resolve: function (fn) { + return fn('arg1', 'arg2'); + } +}); + +assert.equal(resolvedValues.onearg, 'arg1'); +assert.equal(resolvedValues.twoargs, 'arg2'); + +var filterFunction = requireAll({ + dirname: __dirname + '/controllers', + filter: function (fileName) { + var parts = fileName.split('-'); + if (parts[1] !== 'Controller.js') return; + return parts[0]; + } +}); + +assert.deepEqual(filterFunction, { + 'main': { + index: 1, + show: 2, + add: 3, + edit: 4 + }, + + 'other': { + index: 1, + show: 'nothing' + }, + + 'sub-dir': { + 'other': { + index: 1, + show: 2 + } + } +}); diff -Nru node-require-all-0.0.6/.travis.yml node-require-all-3.0.0/.travis.yml --- node-require-all-0.0.6/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ node-require-all-3.0.0/.travis.yml 2018-07-03 04:43:32.000000000 +0000 @@ -0,0 +1,21 @@ +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - '1.8' + - '2.5' + - '3.3' + - '4.9' + - '5.12' + - '6.14' + - '7.10' + - '8.11' + - '9.11' + - '10.5' + +sudo: false + +before_install: npm config set shrinkwrap false + +script: npm test