This works:
var promise = new Future(),
dirs = [],
stat;
Fs.readdir(Root + p, function(error, files){
_.each(files,
readdir
will give you the names of the entries in the folder, not the whole path. This will work:
stat = Fs.statSync(Root + p + "/" + file);
The whole code:
var promise = new Future(),
dirs = [],
stat,
fullPath;
Fs.readdir(Root + p, function(error, files){
_.each(files, function(file) {
fullPath = Root + p + "/" + file;
stat = Fs.statSync(fullPath);
if ( stat.isDirectory() ) {
dirs.push(fullPath);
}
});
promise.return(dirs);
});