]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/utils/cli.ts
5f07a832e7bf57f011cb02a4d7e9e454f2e1353e
[github/Chocobozzz/PeerTube.git] / server / tests / utils / cli.ts
1 import { exec } from 'child_process'
2
3 import { ServerInfo } from './servers'
4
5 function getEnvCli (server?: ServerInfo) {
6 return `NODE_ENV=test NODE_APP_INSTANCE=${server.serverNumber}`
7 }
8
9 async function execCLI (command: string) {
10 return new Promise((res, rej) => {
11 exec(command, (err, stdout, stderr) => {
12 if (err) return rej(err)
13
14 return res(stdout)
15 })
16 })
17 }
18
19 // ---------------------------------------------------------------------------
20
21 export {
22 execCLI,
23 getEnvCli
24 }