lib/get-files.js
async function discoverPackageFilePaths ({ installationId, fullName, defaultBranch, log }) {
  // https://api.github.com/repos/neighbourhoodie/gk-test-lerna-yarn-workspaces/git/trees/master?recursive=1
  const [owner, repo] = fullName.split('/')
  const ghqueue = githubQueue(installationId)
  try {
    const result = (await ghqueue.read(github => github.gitdata.getTree({ owner, repo, tree_sha: defaultBranch, recursive: 1 })))
    const filesInRepo = result.tree && result.tree.length ? result.tree : []
    // Construct an array of all relevant package.json paths
    const relevantPackageFilePaths = filesInRepo.map((item) => {
      // Just pick out the paths, eg. `packages/retext-dutch/package.json`
      return item.path
    }).filter((item) => {
      // We don’t want any package.json files from `node_modules`
      return !(item.includes('node_modules') || item.includes('test/') || item.includes('tests/') || item.includes('elm-package.json')) &&
          item.match(/(.+\/package.json$|^package.json$)/)
    })
    log.info('relevant package file paths', { relevantPackageFilePaths })
    return relevantPackageFilePaths
  } catch (error) {
    log.warn(`An error occured when requesting the recursive git-tree of ${defaultBranch}`, { error: error.message })
    return []
  }
}
async function discoverPackageFilePaths ({ installationId, fullName, defaultBranch, log }) {
  // https://api.github.com/repos/neighbourhoodie/gk-test-lerna-yarn-workspaces/git/trees/master?recursive=1
  const [owner, repo] = fullName.split('/')
  const ghqueue = githubQueue(installationId)
  try {
    const result = (await ghqueue.read(github => github.gitdata.getTree({ owner, repo, tree_sha: defaultBranch, recursive: 1 })))
    const filesInRepo = result.tree && result.tree.length ? result.tree : []
    // Construct an array of all relevant package.json paths
    const relevantPackageFilePaths = filesInRepo.map((item) => {
      // Just pick out the paths, eg. `packages/retext-dutch/package.json`
      return item.path
    }).filter((item) => {
      // We don’t want any package.json files from `node_modules`
      return !(item.includes('node_modules') || item.includes('test/') || item.includes('tests/') || item.includes('elm-package.json')) &&
          item.match(/(.+\/package.json$|^package.json$)/)
    })
    log.info('relevant package file paths', { relevantPackageFilePaths })
    return relevantPackageFilePaths
  } catch (error) {
    log.warn(`An error occured when requesting the recursive git-tree of ${defaultBranch}`, { error: error.message })
    return []
  }
}
async function discoverPackageFilePaths ( { installationId , fullName , defaultBranch , log } ) { // https://api.github.com/repos/neighbourhoodie/gk-test-lerna-yarn-workspaces/git/trees/master?recursive=1 const [ owner , repo ] = fullName . split ( '/' ) const ghqueue = githubQueue ( installationId ) try { const result = ( await ghqueue . read ( github => github . gitdata . getTree ( { owner , repo , tree_sha : defaultBranch , recursive : 1 } ) ) ) const filesInRepo = result . tree && result . tree . length ? result . tree : [ ] // Construct an array of all relevant package.json paths const relevantPackageFilePaths = filesInRepo . map ( ( item ) => { // Just pick out the paths, eg. `packages/retext-dutch/package.json` return item . path } ) . filter ( ( item ) => { // We don’t want any package.json files from `node_modules` return ! ( item . includes ( 'node_modules' ) || item . includes ( 'test/' ) || item . includes ( 'tests/' ) || item . includes ( 'elm-package.json' ) ) && item . match ( / (.+\/package.json$|^package.json$) / ) } ) log . info ( 'relevant package file paths' , { relevantPackageFilePaths } ) return relevantPackageFilePaths } catch ( error ) { log . warn ( ` ${ defaultBranch } ` , { error : error . message } ) return [ ] } }
Returns an array of paths of `package.json` files: [ 'package.json', 'frontend/package.json', 'backend/package.json' ]
Returns an array of paths of package . json files : [ package . json frontend / package . json backend / package . json ]