aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/utils/server.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-14 17:17:01 +0100
committerChocobozzz <me@florianbigard.com>2021-12-14 17:17:01 +0100
commit3cf68b869decf07ff7435fe1436d4f3134df1bf4 (patch)
tree836efe5ddc626fef3ba4c96269efbca305f46256 /client/e2e/src/utils/server.ts
parenta6f919e455f2c6ae8f2194da4aa66824a6bfd09e (diff)
downloadPeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.tar.gz
PeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.tar.zst
PeerTube-3cf68b869decf07ff7435fe1436d4f3134df1bf4.zip
Ability for admins to set default upload values
Diffstat (limited to 'client/e2e/src/utils/server.ts')
-rw-r--r--client/e2e/src/utils/server.ts63
1 files changed, 63 insertions, 0 deletions
diff --git a/client/e2e/src/utils/server.ts b/client/e2e/src/utils/server.ts
new file mode 100644
index 000000000..7089a5c9c
--- /dev/null
+++ b/client/e2e/src/utils/server.ts
@@ -0,0 +1,63 @@
1import { exec, spawn } from 'child_process'
2import { join, resolve } from 'path'
3
4function runServer (appInstance: string, config: any = {}) {
5 const env = Object.create(process.env)
6 env['NODE_ENV'] = 'test'
7 env['NODE_APP_INSTANCE'] = appInstance
8
9 env['NODE_CONFIG'] = JSON.stringify({
10 rates_limit: {
11 api: {
12 max: 5000
13 },
14 login: {
15 max: 5000
16 }
17 },
18 log: {
19 level: 'warn'
20 },
21 signup: {
22 enabled: false
23 },
24 transcoding: {
25 enabled: false
26 },
27
28 ...config
29 })
30
31 const forkOptions = {
32 env,
33 cwd: getRootCWD(),
34 detached: false
35 }
36
37 const p = spawn('node', [ join('dist', 'server.js') ], forkOptions)
38 p.stderr.on('data', data => console.error(data.toString()))
39 p.stdout.on('data', data => console.error(data.toString()))
40
41 return p
42}
43
44function runCommand (command: string) {
45 return new Promise<void>((res, rej) => {
46 const p = exec(command, { cwd: getRootCWD() })
47
48 p.stderr.on('data', data => console.error(data.toString()))
49 p.on('error', err => rej(err))
50 p.on('exit', () => res())
51 })
52}
53
54export {
55 runServer,
56 runCommand
57}
58
59// ---------------------------------------------------------------------------
60
61function getRootCWD () {
62 return resolve('../..')
63}