diff --git a/index.js b/index.js index 641bae1..52c572b 100644 --- a/index.js +++ b/index.js @@ -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; @@ -137,4 +144,4 @@ module.exports = function requireAll(options) { function excludeDirectory(dirname) { return options.excludeDirs && dirname.match(options.excludeDirs); } -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 6fae697..c8a7792 100644 --- a/package.json +++ b/package.json @@ -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": {