mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Move utils to /shared
Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336
This commit is contained in:
parent
71607e4a65
commit
9639bd1757
104 changed files with 318 additions and 196 deletions
24
shared/utils/cli/cli.ts
Normal file
24
shared/utils/cli/cli.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { exec } from 'child_process'
|
||||
|
||||
import { ServerInfo } from '../server/servers'
|
||||
|
||||
function getEnvCli (server?: ServerInfo) {
|
||||
return `NODE_ENV=test NODE_APP_INSTANCE=${server.serverNumber}`
|
||||
}
|
||||
|
||||
async function execCLI (command: string) {
|
||||
return new Promise<string>((res, rej) => {
|
||||
exec(command, (err, stdout, stderr) => {
|
||||
if (err) return rej(err)
|
||||
|
||||
return res(stdout)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
execCLI,
|
||||
getEnvCli
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue