Skip to content

Instantly share code, notes, and snippets.

View jedilando's full-sized avatar

Jan Święcki jedilando

View GitHub Profile
@jedilando
jedilando / gist:3489392
Created August 27, 2012 15:13 — forked from AndrewRayCode/gist:825583
recursive read directory in node.js returning flattened list of files and directories. Added support for empty dirs
// original gist: https://gist.github.com/825583
// I've added support for empty directories
// i.e. when `start` dir was empty callback was not fired,
// now it is fired like this: callback(null, {dirs: [], files: []})
function readDir(start, callback) {
// Use lstat to resolve symlink if we are passed a symlink
fs.lstat(start, function(err, stat) {
if(err) {
return callback(err);
}