'use strict';
const join = require('path').join;
const lstat = require('fs').lstatSync;
const exists = require('fs').existsSync;
/**
 * We want to filter out directories that
 * are not able to be required, that is
 * directories that do not have an index.js
 * file.
 * @param  {Array} list List of filepaths
 * @return {Array}
 */
function filterEmptyDir(list=[]) {
    return list.map((f)=>{
        if(lstat(f).isDirectory() && !exists(join(f, 'index.js'))) {
            return false;
        }
        return f;
    }).filter(Boolean);
}

module.exports = filterEmptyDir;

@@ -48,21 +48,20 @@
 ;%0Aconst 
-lstat
+util
  = requi
@@ -68,22 +68,14 @@
 re('
-fs').lstatSync
+util')
 ;%0Aco
@@ -87,16 +87,31 @@
 xists = 
+util.promisify(
 require(
@@ -126,13 +126,62 @@
 ists
-Sync;
+);%0Aconst lstat = util.promisify(require('fs').lstat);%0A
 %0A/**
@@ -316,16 +316,20 @@
 * file.%0A
+ * %0A
  * @para
@@ -362,16 +362,84 @@
 lepaths%0A
+ * @param %7BString%7D %5BentryFile=index.js%5D Default module entry point %0A
  * @retu
@@ -453,16 +453,22 @@
 ay%7D%0A */%0A
+async 
 function
@@ -491,151 +491,342 @@
 list
-=%5B%5D) %7B%0A    return list.map((f)=%3E%7B%0A        if(lstat(f).isDirectory() && !exists(join(f, 'index.js'))) %7B%0A            return false;%0A    
+ = %5B%5D, entryFile = 'index.js') %7B%0A    let dir, stat, isMod;%0A%0A    let out = %5B%5D,%0A        total = list.length;%0A%0A    for (let i = 0; i %3C total; i++) %7B%0A        dir = list%5Bi%5D;%0A        stat = await lstat(dir);%0A        isMod = await !exists(join(dir, entryFile));%0A%0A        stat.isDirectory() && isMod ? out.push(false) : out.push(dir);%0A
     %7D%0A
-    
+%0A
     
@@ -836,17 +836,11 @@
 urn 
-f;%0A    %7D)
+out
 .fil
@@ -888,9 +888,8 @@
 mptyDir;
-%0A

use async to filer dirs