Skip to content

Instantly share code, notes, and snippets.

@supersha
Created March 11, 2014 01:47
Show Gist options
  • Save supersha/9478009 to your computer and use it in GitHub Desktop.
Save supersha/9478009 to your computer and use it in GitHub Desktop.
var walk = function(path) {
fs.readdirSync(path).forEach(function(file) {
var newPath = path + '/' + file;
var stat = fs.statSync(newPath);
if (stat.isFile()) {
if (/(.*)\.(js$|coffee$)/.test(file)) {
require(newPath);
}
} else if (stat.isDirectory()) {
walk(newPath);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment