Skip to content

Instantly share code, notes, and snippets.

@nazomikan
Forked from FL4TLiN3/dir-lookup.js
Created January 17, 2014 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazomikan/8469757 to your computer and use it in GitHub Desktop.
Save nazomikan/8469757 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
path = require('path');
(function scan(dir) {
fs.readdirSync(dir).forEach(function (item) {
var stat = fs.statSync(path.join(dir, item));
if (stat.isFile()) require(path.join(dir, item));
else if (stat.isDirectory()) scan(path.join(dir, item));
});
})('./lib/some/dir');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment