1
0
Fork 0
peertube/shared/extra-utils/cli/cli.ts

25 lines
517 B
TypeScript
Raw Normal View History

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