Skip to content

Instantly share code, notes, and snippets.

@FL4TLiN3
Created December 25, 2012 12:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FL4TLiN3/4373056 to your computer and use it in GitHub Desktop.
Save FL4TLiN3/4373056 to your computer and use it in GitHub Desktop.
Node.jsで同期的かつ再帰的にディレクトリのルックアップをしてみた。
var fs = require('fs'),
path = require('path');
(function (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()) arguments.callee.caller(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