aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/cli/cli-command.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 10:22:37 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:16 +0200
commitf59545d97a80bf06025bf6343a80d834c7eb237f (patch)
tree7ed34f26b94964e8e707504da5fb90ff9d7486ad /shared/extra-utils/cli/cli-command.ts
parentc1bc8ee4783d6ce3102524e6c2a02b2f0f6aab6d (diff)
downloadPeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.tar.gz
PeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.tar.zst
PeerTube-f59545d97a80bf06025bf6343a80d834c7eb237f.zip
Rename command files
Diffstat (limited to 'shared/extra-utils/cli/cli-command.ts')
-rw-r--r--shared/extra-utils/cli/cli-command.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/shared/extra-utils/cli/cli-command.ts b/shared/extra-utils/cli/cli-command.ts
new file mode 100644
index 000000000..bc1dddc68
--- /dev/null
+++ b/shared/extra-utils/cli/cli-command.ts
@@ -0,0 +1,23 @@
1import { exec } from 'child_process'
2import { AbstractCommand } from '../shared'
3
4export class CLICommand extends AbstractCommand {
5
6 static exec (command: string) {
7 return new Promise<string>((res, rej) => {
8 exec(command, (err, stdout, _stderr) => {
9 if (err) return rej(err)
10
11 return res(stdout)
12 })
13 })
14 }
15
16 getEnv () {
17 return `NODE_ENV=test NODE_APP_INSTANCE=${this.server.internalServerNumber}`
18 }
19
20 async execWithEnv (command: string) {
21 return CLICommand.exec(`${this.getEnv()} ${command}`)
22 }
23}