How to use the gatsby/dist/utils/gatsby-dependents function in gatsby

To help you get started, we’ve selected a few gatsby examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jrestall / gatsby-orchardcore / packages / gatsby-theme-orchardcore-contents / src / WidgetSearcher.ts View on Github external
themes.themes
        ? themes.themes
        : flattenedPlugins.map(plugin => {
            return {
              themeDir: plugin.pluginFilepath,
            }
          })
    )
  
    const filesRegex = `*.+(t|j)s?(x)`
    // Pattern that will be appended to searched directories.
    // It will match any .js, .jsx, .ts, and .tsx files, that are not
    // inside /node_modules.
    const pathRegex = `/{${filesRegex},!(node_modules)/**/${filesRegex}}`

    const modulesThatUseGatsby = await getGatsbyDependents()

    let files = [
      path.join(this.basePath, `src`),
      path.join(this.basePath, `.cache`, `fragments`),
    ]
      .concat(themeDirs.map(additional => path.join(additional, `src`)))
      .concat(modulesThatUseGatsby.map(module => module.path))
      .reduce(
        (merged, folderPath) =>
          merged.concat(
            glob.sync(path.join(folderPath, pathRegex), {
              nodir: true,
            })
          ),
        []
      )