Fix client stats
This commit is contained in:
parent
8ab6f23a00
commit
af11f812ac
|
@ -37,7 +37,7 @@ jobs:
|
||||||
- name: PeerTube client stats
|
- name: PeerTube client stats
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
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
|
- name: PeerTube client lighthouse report
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { root } from '@peertube/peertube-node-utils'
|
||||||
import { readdir, stat } from 'fs/promises'
|
import { readdir, stat } from 'fs/promises'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { root } from '@peertube/peertube-node-utils'
|
|
||||||
|
|
||||||
async function run () {
|
async function run () {
|
||||||
const result = {
|
const result = {
|
||||||
|
@ -14,17 +14,21 @@ async function run () {
|
||||||
run()
|
run()
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
|
|
||||||
async function buildResult (path: string) {
|
async function buildResult (path: string, root = path) {
|
||||||
const distFiles = await readdir(path)
|
const distFiles = await readdir(path)
|
||||||
|
|
||||||
const files: { name: string, size: number }[] = []
|
let files: { name: string, size: number }[] = []
|
||||||
|
|
||||||
for (const file of distFiles) {
|
for (const file of distFiles) {
|
||||||
const filePath = join(path, file)
|
const filePath = join(path, file)
|
||||||
|
|
||||||
const statsResult = await stat(filePath)
|
const statsResult = await stat(filePath)
|
||||||
|
if (statsResult.isDirectory()) {
|
||||||
|
files = files.concat(await buildResult(filePath, root))
|
||||||
|
}
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
name: file,
|
name: filePath.replace(new RegExp(`^${root}/`), ''),
|
||||||
size: statsResult.size
|
size: statsResult.size
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue