aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/client-build-stats.ts
blob: 3b26aa64746f2aa879eeeb9a0c7ac678064d0c09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { readdir, stat } from 'fs/promises'
import { join } from 'path'
import { root } from '@peertube/peertube-node-utils'

async function run () {
  const result = {
    app: await buildResult(join(root(), 'client', 'dist', 'en-US')),
    embed: await buildResult(join(root(), 'client', 'dist', 'standalone', 'videos'))
  }

  console.log(JSON.stringify(result))
}

run()
  .catch(err => console.error(err))

async function buildResult (path: string) {
  const distFiles = await readdir(path)

  const files: { name: string, size: number }[] = []

  for (const file of distFiles) {
    const filePath = join(path, file)

    const statsResult = await stat(filePath)
    files.push({
      name: file,
      size: statsResult.size
    })
  }

  return files
}