index.js
function crawlDirectoryWithFS(parent, sync) {
    return fsCmd('readdir', sync, parent).then(function (things) {
        return Q.all(things.map(function (file) {
            file = path.join(parent, file);
            return Q.all([file, fsCmd('stat', sync, file)]);
        }));
    }).then(function (stats) {
        return Q.all(stats.map(function (args) {
            var file = args[0], stat = args[1];
            if (stat.isDirectory()) {
                return crawlDirectoryWithFS(file, sync);
            }
            return file;
        }));
    }).then(function (grouped) {
        return [].concat.apply([], grouped);
    });
}
function crawlDirectoryWithFS(parent, sync) {
    return fsCmd('readdir', sync, parent).then(function (things) {
        return Q.all(things.map(function (file) {
            file = path.join(parent, file);
            return Q.all([file, fsCmd('stat', sync, file)]);
        }));
    }).then(function (stats) {
        return Q.all(stats.map(function (args) {
            var file = args[0], stat = args[1];
            if (stat.isDirectory()) {
                return crawlDirectoryWithFS(file, sync);
            }
            return file;
        }));
    }).then(function (grouped) {
        return [].concat.apply([], grouped);
    });
}
function crawlDirectoryWithFS ( parent , sync ) { return fsCmd ( 'readdir' , sync , parent ) . then ( function ( things ) { return Q . all ( things . map ( function ( file ) { file = path . join ( parent , file ) ; return Q . all ( [ file , fsCmd ( 'stat' , sync , file ) ] ) ; } ) ) ; } ) . then ( function ( stats ) { return Q . all ( stats . map ( function ( args ) { var file = args [ 0 ] , stat = args [ 1 ] ; if ( stat . isDirectory ( ) ) { return crawlDirectoryWithFS ( file , sync ) ; } return file ; } ) ) ; } ) . then ( function ( grouped ) { return [ ] . concat . apply ( [ ] , grouped ) ; } ) ; }
Recursively crawl a directory for all of it's files.
Recursively crawl a directory for all of it s files .