src/lib/bin.js
/**
 * Recursively construct Test Suites tree from a directory path.
 * @param {string} dir Path to the directory.
 * @todo filter out non-js files
 */
Recursively construct Test Suites tree from a directory path.
@param {string} dir Path to the directory.
@todo filter out non-js files
Recursively construct Test Suites tree from a directory path . @param { string } dir Path to the directory . @todo filter out non - js files
async function buildDirectory(dir) {
  const content = 
    (await makePromise(readdir, dir))
  const res = content.reduce(async (acc, node) => {
    const accRes = await acc
    const path = join(dir, node)
    const stat =  (await makePromise(lstat, path))
    let r
    let name
    if (stat.isFile()) {
      const p = resolve(path)
      r = require(p) 
      name = replaceFilename(node)
    } else if (stat.isDirectory()) {
      r = await buildDirectory(path)
      name = node
    }
    if (accRes[name]) {
      console.warn('Merging %s with %s in %s', name, node, dir)
      accRes[name] = safeMerge(accRes[name], r)
      return accRes
    } else {
      return {
        ...accRes,
        [name]: r,
      }
    }
  }, {})
  return res
}
async function buildDirectory ( dir ) { const content = ( await makePromise ( readdir , dir ) ) const res = content . reduce ( async ( acc , node ) => { const accRes = await acc const path = join ( dir , node ) const stat = ( await makePromise ( lstat , path ) ) let r let name if ( stat . isFile ( ) ) { const p = resolve ( path ) r = require ( p ) name = replaceFilename ( node ) } else if ( stat . isDirectory ( ) ) { r = await buildDirectory ( path ) name = node } if ( accRes [ name ] ) { console . warn ( 'Merging %s with %s in %s' , name , node , dir ) accRes [ name ] = safeMerge ( accRes [ name ] , r ) return accRes } else { return { ... accRes , [ name ] : r , } } } , { } ) return res }
Recursively construct Test Suites tree from a directory path.
Recursively construct Test Suites tree from a directory path .
/** @type {!Array<string>} */ /** @type {fs.Stats} */ // await import(p) // to avoid that, could keep the filenames here, // but don't print them in the reporter