aboutsummaryrefslogblamecommitdiffhomepage
path: root/shared/extra-utils/cli/cli.ts
blob: d532b62b02e4dbf8b86b9f65583741fc12413d2b (plain) (tree)
1
2
3
4
5
6
7
8
9

                                    
                                              




                                                                 
                                           
                                            













                                                                              
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
}