client-build-stats.ts 762 B

123456789101112131415161718192021222324252627282930313233
  1. import { readdir, stat } from 'fs/promises'
  2. import { join } from 'path'
  3. import { root } from '@peertube/peertube-node-utils'
  4. async function run () {
  5. const result = {
  6. app: await buildResult(join(root(), 'client', 'dist', 'en-US')),
  7. embed: await buildResult(join(root(), 'client', 'dist', 'standalone', 'videos'))
  8. }
  9. console.log(JSON.stringify(result))
  10. }
  11. run()
  12. .catch(err => console.error(err))
  13. async function buildResult (path: string) {
  14. const distFiles = await readdir(path)
  15. const files: { name: string, size: number }[] = []
  16. for (const file of distFiles) {
  17. const filePath = join(path, file)
  18. const statsResult = await stat(filePath)
  19. files.push({
  20. name: file,
  21. size: statsResult.size
  22. })
  23. }
  24. return files
  25. }