Created
December 25, 2012 12:57
-
-
Save FL4TLiN3/4373056 to your computer and use it in GitHub Desktop.
Node.jsで同期的かつ再帰的にディレクトリのルックアップをしてみた。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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