function listBuildFiles(rootDir, subDir = '') {
  const dir = path.posix.join(rootDir, subDir);
  return fs.readdirSync(dir).reduce((files, file) => {
    const fullPath = path.posix.join(dir, file);
    const relPath = path.posix.join(subDir, file);
    const isDirectory = fs.statSync(fullPath).isDirectory();
    if (isDirectory) {
      return files.concat(listBuildFiles(rootDir, relPath));
    } else if (file === 'BUILD' || file === 'BUILD.bazel') {
      return files.concat(relPath);
    } else {
      return files;
    }
  }, []);
}
/**
 * Returns an array of all BUILD the files under a directory as relative
 * paths to the directory.
 */
Returns an array of all BUILD the files under a directory as relative
paths to the directory.
Returns an array of all BUILD the files under a directory as relative paths to the directory .
function listBuildFiles(rootDir, subDir = '') {
  const dir = path.posix.join(rootDir, subDir);
  return fs.readdirSync(dir).reduce((files, file) => {
    const fullPath = path.posix.join(dir, file);
    const relPath = path.posix.join(subDir, file);
    const isDirectory = fs.statSync(fullPath).isDirectory();
    if (isDirectory) {
      return files.concat(listBuildFiles(rootDir, relPath));
    } else if (file === 'BUILD' || file === 'BUILD.bazel') {
      return files.concat(relPath);
    } else {
      return files;
    }
  }, []);
}
function listBuildFiles ( rootDir , subDir = '' ) { const dir = path . posix . join ( rootDir , subDir ) ; return fs . readdirSync ( dir ) . reduce ( ( files , file ) => { const fullPath = path . posix . join ( dir , file ) ; const relPath = path . posix . join ( subDir , file ) ; const isDirectory = fs . statSync ( fullPath ) . isDirectory ( ) ; if ( isDirectory ) { return files . concat ( listBuildFiles ( rootDir , relPath ) ) ; } else if ( file === 'BUILD' || file === 'BUILD.bazel' ) { return files . concat ( relPath ) ; } else { return files ; } } , [ ] ) ; }
Returns an array of all BUILD the files under a directory as relative
 paths to the directory.
Returns an array of all BUILD the files under a directory as relative paths to the directory .