diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-10 16:16:46 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-10 16:16:46 +0100 |
commit | 99bb59fa7796ed2dc25e7771d916411ebb1b9279 (patch) | |
tree | a345f33a7efc97589ee5a41446a3a79dfc91c755 | |
parent | 45ba09fef3b970fb916ffb1b0ac7509db7bbdde6 (diff) | |
download | PeerTube-99bb59fa7796ed2dc25e7771d916411ebb1b9279.tar.gz PeerTube-99bb59fa7796ed2dc25e7771d916411ebb1b9279.tar.zst PeerTube-99bb59fa7796ed2dc25e7771d916411ebb1b9279.zip |
Add client build stats script
-rw-r--r-- | scripts/client-build-stats.ts | 33 |
1 files changed, 33 insertions, 0 deletions
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 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import { readdir, stat } from 'fs-extra' | ||
5 | import { join } from 'path' | ||
6 | import { root } from '@server/helpers/core-utils' | ||
7 | |||
8 | async function run () { | ||
9 | const result = { | ||
10 | app: await buildResult(join(root(), 'client', 'dist', 'en-US')), | ||
11 | embed: await buildResult(join(root(), 'client', 'dist', 'standalone', 'videos')) | ||
12 | } | ||
13 | |||
14 | console.log(JSON.stringify(result)) | ||
15 | } | ||
16 | |||
17 | run() | ||
18 | .catch(err => console.error(err)) | ||
19 | |||
20 | async function buildResult (path: string) { | ||
21 | const distFiles = await readdir(path) | ||
22 | |||
23 | const files: { [ name: string ]: number } = {} | ||
24 | |||
25 | for (const file of distFiles) { | ||
26 | const filePath = join(path, file) | ||
27 | |||
28 | const statsResult = await stat(filePath) | ||
29 | files[file] = statsResult.size | ||
30 | } | ||
31 | |||
32 | return files | ||
33 | } | ||