PeerTube/server/tests/utils/cli.ts

25 lines
509 B
TypeScript
Raw Normal View History

2017-09-07 08:27:35 -05:00
import { exec } from 'child_process'
import { ServerInfo } from './servers'
function getEnvCli (server?: ServerInfo) {
return `NODE_ENV=test NODE_APP_INSTANCE=${server.serverNumber}`
}
async function execCLI (command: string) {
2017-09-07 10:58:09 -05:00
return new Promise<string>((res, rej) => {
2017-09-07 08:27:35 -05:00
exec(command, (err, stdout, stderr) => {
if (err) return rej(err)
return res(stdout)
})
})
}
// ---------------------------------------------------------------------------
export {
execCLI,
getEnvCli
}