async function readPackageTree(targetPath, matcher, mode) {
  const folderName = mode === 'npm' ? 'node_modules' : 'bower_components';
  const potentialPaths = await globby(`${folderName}/**/*`, {
    onlyDirectories: true,
    fs: fsAdapter.fs,
    cwd: targetPath,
    absolute: true,
  });
  const matchingPaths = potentialPaths.filter(potentialPath => {
    // Only dirs that are direct children of node_modules. So '**/node_modules/a' will match, but '**/node_modules/a/b' won't
    const [, projectName] =
      toPosixPath(potentialPath).match(new RegExp(`^.*/${folderName}/([^/]*)$`)) || [];
    return matcher ? matcher(projectName) : true;
  });
  return matchingPaths;
}
@param {string} targetPath
@param {((s:string) => boolean)|null} matcher
@param {'npm'|'bower'} [mode]