diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index 37146a94c..b6a4e4295 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -37,7 +37,7 @@ jobs: - name: PeerTube client stats if: github.event_name != 'pull_request' run: | - npm run client:build-stats > client-build-stats.json + npm run -s client:build-stats > client-build-stats.json - name: PeerTube client lighthouse report if: github.event_name != 'pull_request' diff --git a/scripts/client-build-stats.ts b/scripts/client-build-stats.ts index 3b26aa647..d8958824f 100644 --- a/scripts/client-build-stats.ts +++ b/scripts/client-build-stats.ts @@ -1,6 +1,6 @@ +import { root } from '@peertube/peertube-node-utils' import { readdir, stat } from 'fs/promises' import { join } from 'path' -import { root } from '@peertube/peertube-node-utils' async function run () { const result = { @@ -14,17 +14,21 @@ async function run () { run() .catch(err => console.error(err)) -async function buildResult (path: string) { +async function buildResult (path: string, root = path) { const distFiles = await readdir(path) - const files: { name: string, size: number }[] = [] + let files: { name: string, size: number }[] = [] for (const file of distFiles) { const filePath = join(path, file) const statsResult = await stat(filePath) + if (statsResult.isDirectory()) { + files = files.concat(await buildResult(filePath, root)) + } + files.push({ - name: file, + name: filePath.replace(new RegExp(`^${root}/`), ''), size: statsResult.size }) }