From 99bb59fa7796ed2dc25e7771d916411ebb1b9279 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Feb 2021 16:16:46 +0100 Subject: [PATCH] Add client build stats script --- scripts/client-build-stats.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 scripts/client-build-stats.ts diff --git a/scripts/client-build-stats.ts b/scripts/client-build-stats.ts new file mode 100644 index 000000000..a6085902c --- /dev/null +++ b/scripts/client-build-stats.ts @@ -0,0 +1,33 @@ +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) + + const files: { [ name: string ]: number } = {} + + for (const file of distFiles) { + const filePath = join(path, file) + + const statsResult = await stat(filePath) + files[file] = statsResult.size + } + + return files +} -- 2.41.0