1
0
Fork 0
peertube/scripts/client-build-stats.ts

34 lines
762 B
TypeScript
Raw Normal View History

import { readdir, stat } from 'fs/promises'
2021-02-10 10:16:46 -05:00
import { join } from 'path'
import { root } from '@peertube/peertube-node-utils'
2021-02-10 10:16:46 -05:00
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)
2021-02-11 02:41:12 -05:00
const files: { name: string, size: number }[] = []
2021-02-10 10:16:46 -05:00
for (const file of distFiles) {
const filePath = join(path, file)
const statsResult = await stat(filePath)
2021-02-11 02:41:12 -05:00
files.push({
name: file,
size: statsResult.size
})
2021-02-10 10:16:46 -05:00
}
return files
}