diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/bulk/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/cli/cli.ts | 33 | ||||
-rw-r--r-- | shared/extra-utils/cli/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/index.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 8 |
5 files changed, 30 insertions, 17 deletions
diff --git a/shared/extra-utils/bulk/index.ts b/shared/extra-utils/bulk/index.ts new file mode 100644 index 000000000..5d2f9d3ad --- /dev/null +++ b/shared/extra-utils/bulk/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './bulk' | |||
diff --git a/shared/extra-utils/cli/cli.ts b/shared/extra-utils/cli/cli.ts index c62e170bb..1bf100869 100644 --- a/shared/extra-utils/cli/cli.ts +++ b/shared/extra-utils/cli/cli.ts | |||
@@ -1,24 +1,27 @@ | |||
1 | import { exec } from 'child_process' | 1 | import { exec } from 'child_process' |
2 | import { AbstractCommand } from '../shared' | ||
2 | 3 | ||
3 | import { ServerInfo } from '../server/servers' | 4 | class CLICommand extends AbstractCommand { |
4 | 5 | ||
5 | function getEnvCli (server?: ServerInfo) { | 6 | static exec (command: string) { |
6 | return `NODE_ENV=test NODE_APP_INSTANCE=${server.internalServerNumber}` | 7 | return new Promise<string>((res, rej) => { |
7 | } | 8 | exec(command, (err, stdout, _stderr) => { |
8 | 9 | if (err) return rej(err) | |
9 | async function execCLI (command: string) { | ||
10 | return new Promise<string>((res, rej) => { | ||
11 | exec(command, (err, stdout, stderr) => { | ||
12 | if (err) return rej(err) | ||
13 | 10 | ||
14 | return res(stdout) | 11 | return res(stdout) |
12 | }) | ||
15 | }) | 13 | }) |
16 | }) | 14 | } |
17 | } | ||
18 | 15 | ||
19 | // --------------------------------------------------------------------------- | 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 | } | ||
20 | 24 | ||
21 | export { | 25 | export { |
22 | execCLI, | 26 | CLICommand |
23 | getEnvCli | ||
24 | } | 27 | } |
diff --git a/shared/extra-utils/cli/index.ts b/shared/extra-utils/cli/index.ts new file mode 100644 index 000000000..8a3f31e2f --- /dev/null +++ b/shared/extra-utils/cli/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './cli' | |||
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 87ee8abba..4bf057492 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | export * from './bulk/bulk' | 1 | export * from './bulk' |
2 | 2 | ||
3 | export * from './cli/cli' | 3 | export * from './cli' |
4 | 4 | ||
5 | export * from './custom-pages/custom-pages' | 5 | export * from './custom-pages/custom-pages' |
6 | 6 | ||
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 28e431e94..1b0775421 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -6,6 +6,8 @@ import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra | |||
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { randomInt } from '../../core-utils/miscs/miscs' | 7 | import { randomInt } from '../../core-utils/miscs/miscs' |
8 | import { VideoChannel } from '../../models/videos' | 8 | import { VideoChannel } from '../../models/videos' |
9 | import { BulkCommand } from '../bulk' | ||
10 | import { CLICommand } from '../cli' | ||
9 | import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs' | 11 | import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs' |
10 | import { makeGetRequest } from '../requests/requests' | 12 | import { makeGetRequest } from '../requests/requests' |
11 | 13 | ||
@@ -60,6 +62,9 @@ interface ServerInfo { | |||
60 | } | 62 | } |
61 | 63 | ||
62 | videos?: { id: number, uuid: string }[] | 64 | videos?: { id: number, uuid: string }[] |
65 | |||
66 | bulkCommand?: BulkCommand | ||
67 | cliCommand?: CLICommand | ||
63 | } | 68 | } |
64 | 69 | ||
65 | function parallelTests () { | 70 | function parallelTests () { |
@@ -265,6 +270,9 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
265 | } catch { /* empty */ } | 270 | } catch { /* empty */ } |
266 | }) | 271 | }) |
267 | 272 | ||
273 | server.bulkCommand = new BulkCommand(server) | ||
274 | server.cliCommand = new CLICommand(server) | ||
275 | |||
268 | res(server) | 276 | res(server) |
269 | }) | 277 | }) |
270 | }) | 278 | }) |