Created
February 12, 2015 21:13
-
-
Save tomchentw/9328ede9aa373cf8b6d6 to your computer and use it in GitHub Desktop.
listing directory
This file contains hidden or 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
/* | |
* This is a synchronized vesion. Please rewrite in async version using Promise. | |
* Note: You may directly use https://github.com/normalize/mz | |
* | |
*/ | |
var walkSync = function(dir, filelist) { | |
var fs = fs || require('fs'), | |
files = fs.readdirSync(dir); | |
filelist = filelist || []; | |
files.forEach(function(file) { | |
if (fs.statSync(dir + file).isDirectory()) { | |
filelist = walkSync(dir + file + '/', filelist); | |
} | |
else { | |
filelist.push(file); | |
} | |
}); | |
return filelist; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment