diff --git a/README.md b/README.md index 75459ef..85fe28b 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -17,7 +17,7 @@ or in package.json { ... "dependencies": { - "requireindex": "~0.1.3" + "requireindex": "~0.1.4" } } ``` diff --git a/index.js b/index.js index d214eda..9f96bdd 100644 --- a/index.js +++ b/index.js @@ -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; -}; \ No newline at end of file + return requires; + }; +})(); \ No newline at end of file diff --git a/package.json b/package.json index 05323b0..1bf7100 100644 --- a/package.json +++ b/package.json @@ -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",