src/import.js
async function _filesInDirectory(dirPath, options) {
  const basedir = options.basedir || getCallingDir();
  const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
  let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));

  try {
    const files = (await readDir(resolvedDirPath));
    if (options.rescursive) {
      const dirs = chain(await Promise.all(chain(files)
        .map(fileName=>path.resolve(resolvedDirPath, fileName))
        .map(async (file)=>{
          const stat = await lstat(file);
          if (stat.isDirectory()) return file;
        })
        .value())).filter(file=>file);
      if (dirs.value().length) files.push(...(await Promise.all(
        dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value()
      )));
    }
    return chain(files)
      .flattenDeep()
      .filter(fileName=>xExt.test(fileName))
      .map(fileName=>path.resolve(resolvedDirPath, fileName))
      .value();
  } catch (err) {
    return [];
  }
}
async function _filesInDirectory(dirPath, options) {
  const basedir = options.basedir || getCallingDir();
  const resolvedDirPath = basedir?path.resolve(basedir, dirPath):dirPath;
  let xExt = _getExtensionRegEx(options.extension || settings.get('extensions'));

  try {
    const files = (await readDir(resolvedDirPath));
    if (options.rescursive) {
      const dirs = chain(await Promise.all(chain(files)
        .map(fileName=>path.resolve(resolvedDirPath, fileName))
        .map(async (file)=>{
          const stat = await lstat(file);
          if (stat.isDirectory()) return file;
        })
        .value())).filter(file=>file);
      if (dirs.value().length) files.push(...(await Promise.all(
        dirs.map(dirPath=>_filesInDirectory(dirPath, options)).value()
      )));
    }
    return chain(files)
      .flattenDeep()
      .filter(fileName=>xExt.test(fileName))
      .map(fileName=>path.resolve(resolvedDirPath, fileName))
      .value();
  } catch (err) {
    return [];
  }
}
async function _filesInDirectory ( dirPath , options ) { const basedir = options . basedir || getCallingDir ( ) ; const resolvedDirPath = basedir ? path . resolve ( basedir , dirPath ) : dirPath ; let xExt = _getExtensionRegEx ( options . extension || settings . get ( 'extensions' ) ) ; try { const files = ( await readDir ( resolvedDirPath ) ) ; if ( options . rescursive ) { const dirs = chain ( await Promise . all ( chain ( files ) . map ( fileName => path . resolve ( resolvedDirPath , fileName ) ) . map ( async ( file ) => { const stat = await lstat ( file ) ; if ( stat . isDirectory ( ) ) return file ; } ) . value ( ) ) ) . filter ( file => file ) ; if ( dirs . value ( ) . length ) files . push ( ... ( await Promise . all ( dirs . map ( dirPath => _filesInDirectory ( dirPath , options ) ) . value ( ) ) ) ) ; } return chain ( files ) . flattenDeep ( ) . filter ( fileName => xExt . test ( fileName ) ) . map ( fileName => path . resolve ( resolvedDirPath , fileName ) ) . value ( ) ; } catch ( err ) { return [ ] ; } }
Get a list of files in the directory.

@private
@param {string} dirPath          Directory path to scan.
@param {Object} [options]        Import options object.
@returns {Promise.<string[]>}    Promise resolving to array of files.
Get a list of files in the directory .