PeerTube/scripts/client-build-stats.ts

37 lines
845 B
TypeScript
Raw Normal View History

2021-02-10 16:16:46 +01:00
import { registerTSPaths } from '../server/helpers/register-ts-paths'
registerTSPaths()
import { readdir, stat } from 'fs-extra'
import { join } from 'path'
import { root } from '@server/helpers/core-utils'
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 08:41:12 +01:00
const files: { name: string, size: number }[] = []
2021-02-10 16:16:46 +01:00
for (const file of distFiles) {
const filePath = join(path, file)
const statsResult = await stat(filePath)
2021-02-11 08:41:12 +01:00
files.push({
name: file,
size: statsResult.size
})
2021-02-10 16:16:46 +01:00
}
return files
}