export function getBasePath()

in test-reporter/src/utils/path-utils.ts [21:39]


export function getBasePath(path: string, trackedFiles: string[]): string | undefined {
  if (trackedFiles.includes(path)) {
    return ''
  }

  let max = ''
  for (const file of trackedFiles) {
    if (path.endsWith(file) && file.length > max.length) {
      max = file
    }
  }

  if (max === '') {
    return undefined
  }

  const base = path.substr(0, path.length - max.length)
  return base
}