Skip to content

Commit

Permalink
add case-insensitive lex sort to files prior to requiring [#2]
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhandley committed May 30, 2012
1 parent 7fcea78 commit c37130e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
var requires = {};

if (arguments.length === 1) {
fs.readdirSync(dir).forEach(function(filename) {
var files = fs.readdirSync(dir);
files.sort(function(a,b) { return a.toLowerCase() - b.toLowerCase() });

files.forEach(function(filename) {

if ((filename === 'index.js') || (filename[0] === '_')) { return; }

Expand Down
4 changes: 3 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ try {

assert.equal(('_private' in lib), false);
assert.equal(('ignored' in lib.bar.fed), false);


assert.equal(Object.keys(lib)[0], 'bam');

console.log("All tests passed.");

} catch (error) {
Expand Down

0 comments on commit c37130e

Please sign in to comment.