diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 15:27:35 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 15:54:34 +0200 |
commit | fdbda9e3d6564ec908733c7019305f6a3c363a9f (patch) | |
tree | c596034156f167e7cfafe41c4a3fc6adda488a0d /server/tests/utils/cli.ts | |
parent | 04de542abd940f9d2ca213fba3c68580c6c9b78a (diff) | |
download | PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.gz PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.zst PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.zip |
Add tests for npm run scripts
Diffstat (limited to 'server/tests/utils/cli.ts')
-rw-r--r-- | server/tests/utils/cli.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/tests/utils/cli.ts b/server/tests/utils/cli.ts new file mode 100644 index 000000000..5f07a832e --- /dev/null +++ b/server/tests/utils/cli.ts | |||
@@ -0,0 +1,24 @@ | |||
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 | } | ||