<commit_before>import { store } from "../redux"
import rpt from "read-package-tree"

// Returns [Object] with name and path
module.exports = async () => {
  const { program } = store.getState()
  const allNodeModules = await rpt(program.directory)
  return allNodeModules.children.filter(
    node =>
      (node.package.dependencies && node.package.dependencies[`gatsby`]) ||
      (node.package.peerDependencies && node.package.peerDependencies[`gatsby`])
  )
}<commit_msg>feat(gatsby): Switch to name based package filtering for speed (#15308)<commit_after>import { store } from "../redux"
import rpt from "read-package-tree"
import { promisify } from "util"

const rptAsync = promisify(rpt)
// Returns [Object] with name and path
module.exports = async () => {
  const { program } = store.getState()
  const allNodeModules = await rptAsync(program.directory, (node, moduleName) =>
    /gatsby/.test(moduleName)
  )
  return allNodeModules.children
}
{'fraction_non_alphanumeric': 0.1353620146904512, 'fraction_numerical': 0.005246589716684155, 'mean_word_length': 4.329608938547486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3512431', 'n_tokens_mistral': 301, 'n_tokens_neox': 293, 'n_words': 74}