Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an option so that the file result can be sorted #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ module.exports = function requireAll(options) {
else throw new Error('Directory not found: ' + options.dirname);
}

// Sort the result
if (!!options.sortResult) {
files = files.sort(function(a, b) {
return a < b ? -1 : 1;
});
}

// Iterate through files in the current directory
files.forEach(function(file) {
var filepath = options.dirname + '/' + file;
Expand Down Expand Up @@ -137,4 +144,4 @@ module.exports = function requireAll(options) {
function excludeDirectory(dirname) {
return options.excludeDirs && dirname.match(options.excludeDirs);
}
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "include-all",
"version": "0.1.6",
"version": "0.1.7",
"description": "An easy way to include all node.js modules within a directory. This is a fork of felixge's awesome module, require-all (https://github.com/felixge/node-require-all) which adds the ability to mark an include as **optional**.",
"main": "index.js",
"directories": {
Expand Down