Fix client stats
This commit is contained in:
parent
8ab6f23a00
commit
af11f812ac
2 changed files with 9 additions and 5 deletions
2
.github/workflows/stats.yml
vendored
2
.github/workflows/stats.yml
vendored
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue