Fix client stats

pull/6416/merge
Chocobozzz 2024-07-03 15:59:26 +02:00
parent 8ab6f23a00
commit af11f812ac
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 9 additions and 5 deletions

View File

@ -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'

View File

@ -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
})
}