Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/tests / src / jest / deps.file.ts
Size: Mime:
import { resolve } from 'path'
import { existsSync } from 'fs'

export function resolveToRoot(fileName: string) {
  return resolve(process.cwd(), fileName)
}
export function toRootPath(fileName: string): string {
  if (fileName.startsWith('/')) {
    return fileName
  } else {
    const absolutePath = resolveToRoot(fileName)
    return absolutePath
  }
}
export function pathIfExists(fileName: string): string | false {
  const absolutePath = toRootPath(fileName)
  if (existsSync(absolutePath) === true) {
    return absolutePath
  } else {
    return false
  }
}
export function fromFileNamesToFirstExistingPath(
  ...fileNames: string[]
): string {
  const found =
    fileNames.find(x => pathIfExists(x) !== false) ||
    '@EMPTY:fromFileNamesToFirstExistingPath'
  return toRootPath(found)
}