Skip to content

Commit

Permalink
blame coffee
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhandley committed May 6, 2012
1 parent 98dc680 commit 7fcea78
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Write minimal node index.js files that require and export siblings by file basen

# Latest Version

0.1.3
0.1.4

# Installation
```
Expand All @@ -17,7 +17,7 @@ or in package.json
{
...
"dependencies": {
"requireindex": "~0.1.3"
"requireindex": "~0.1.4"
}
}
```
Expand Down
40 changes: 21 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
var fs = require('fs'),
path = require('path');
(function() {
var fs = require('fs'),
path = require('path');

module.exports = function(dir, basenames) {
var requires = {};
module.exports = function(dir, basenames) {
var requires = {};

if (arguments.length === 1) {
fs.readdirSync(dir).forEach(function(filename) {
if (arguments.length === 1) {
fs.readdirSync(dir).forEach(function(filename) {

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

filename = path.basename(filename, path.extname(filename));
var filepath = path.join(dir, filename);
filename = path.basename(filename, path.extname(filename));
var filepath = path.join(dir, filename);

requires[filename] = require(filepath);
});
requires[filename] = require(filepath);
});

} else {
basenames.forEach(function(basename) {
var filepath = path.join(dir, basename);
requires[basename] = require(filepath);
});
}
} else {
basenames.forEach(function(basename) {
var filepath = path.join(dir, basename);
requires[basename] = require(filepath);
});
}

return requires;
};
return requires;
};
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"description": "Write minimal node index.js files that require and export siblings by file basename",

"version": "0.1.3",
"version": "0.1.4",

"license" : "MIT",

Expand Down

0 comments on commit 7fcea78

Please sign in to comment.