hunk.code_window:       sinon: 9.0.2
         supi: 'workspace:0.39.0-alpha.5'
         table: 5.4.6
         version-selector-type: ^3.0.0
         write-json-file: 4.2.1
         write-yaml-file: ^4.1.0
  
hunk.labels: keep keep add keep keep keep
hunk.after_edit:       tempy: ^0.5.0
  
hunk.file_path: pnpm-lock.yaml
hunk.type: add
file: import PnpmError from '@pnpm/error'
  import execa = require('execa')
  import findUp = require('find-up')
  import isSubdir = require('is-subdir')
  import path = require('path')
  
  export default async function changedSince (packageDirs: string[], commit: string, opts: { workspaceDir: string }): Promise<string[]> {
    const repoRoot = path.resolve(await findUp('.git', { cwd: opts.workspaceDir, type: 'directory' }) || opts.workspaceDir, '..')
    let changedDirs = Array.from(
      await getChangedDirsSinceCommit(commit, opts.workspaceDir),
    ).map(changedDir => path.join(repoRoot, changedDir))
    const changedPkgs = []
    for (const packageDir of packageDirs.sort((pkgDir1, pkgDir2) => pkgDir2.length - pkgDir1.length)) {
      if (
        changedDirs.some(changedDir => isSubdir(packageDir, changedDir))
      ) {
        changedDirs = changedDirs.filter((changedDir) => !isSubdir(packageDir, changedDir))
        changedPkgs.push(packageDir)
      }
    }
    return changedPkgs
  }
  
  async function getChangedDirsSinceCommit (commit: string, workingDir: string) {
    let diff!: string
    try {
      diff = (
        await execa('git', [
          'diff',
          '--name-only',
          commit,
          '--',
          workingDir,
        ], { cwd: workingDir })
      ).stdout
    } catch (err) {
      throw new PnpmError('FILTER_CHANGED', `Filtering by changed packages failed. ${err.stderr}`)
    }
    const changedDirs = new Set<string>()
  
    if (!diff) {
      return changedDirs
    }
    const changedFiles = diff.split('\n')
  
    for (const changedFile of changedFiles) {
      changedDirs.add(path.dirname(changedFile))
    }
    return changedDirs
  }
  