Federated video streaming platform using ActivityPub and P2P in the web browser with Angular. https://joinpeertube.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.3 KiB

  1. import { basename, extname, isAbsolute, join, resolve } from 'path'
  2. let rootPath: string
  3. function root () {
  4. if (rootPath) return rootPath
  5. rootPath = __dirname
  6. if (basename(rootPath) === 'tools') rootPath = resolve(rootPath, '..')
  7. if (basename(rootPath) === 'scripts') rootPath = resolve(rootPath, '..')
  8. if (basename(rootPath) === 'common') rootPath = resolve(rootPath, '..')
  9. if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..')
  10. if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..')
  11. if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..')
  12. if (basename(rootPath) === 'dist') rootPath = resolve(rootPath, '..')
  13. return rootPath
  14. }
  15. function buildPath (path: string) {
  16. if (isAbsolute(path)) return path
  17. return join(root(), path)
  18. }
  19. function getLowercaseExtension (filename: string) {
  20. const ext = extname(filename) || ''
  21. return ext.toLowerCase()
  22. }
  23. function buildAbsoluteFixturePath (path: string, customCIPath = false) {
  24. if (isAbsolute(path)) return path
  25. if (customCIPath && process.env.GITHUB_WORKSPACE) {
  26. return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)
  27. }
  28. return join(root(), 'server', 'tests', 'fixtures', path)
  29. }
  30. export {
  31. root,
  32. buildPath,
  33. buildAbsoluteFixturePath,
  34. getLowercaseExtension
  35. }