cli.ts 517 B

123456789101112131415161718192021222324
  1. import { exec } from 'child_process'
  2. import { ServerInfo } from '../server/servers'
  3. function getEnvCli (server?: ServerInfo) {
  4. return `NODE_ENV=test NODE_APP_INSTANCE=${server.serverNumber}`
  5. }
  6. async function execCLI (command: string) {
  7. return new Promise<string>((res, rej) => {
  8. exec(command, (err, stdout, stderr) => {
  9. if (err) return rej(err)
  10. return res(stdout)
  11. })
  12. })
  13. }
  14. // ---------------------------------------------------------------------------
  15. export {
  16. execCLI,
  17. getEnvCli
  18. }