2017-09-07 09:27:35 -04:00
|
|
|
import { exec } from 'child_process'
|
2021-07-05 10:37:50 -04:00
|
|
|
import { AbstractCommand } from '../shared'
|
2017-09-07 09:27:35 -04:00
|
|
|
|
2021-07-05 10:37:50 -04:00
|
|
|
class CLICommand extends AbstractCommand {
|
2017-09-07 09:27:35 -04:00
|
|
|
|
2021-07-05 10:37:50 -04:00
|
|
|
static exec (command: string) {
|
|
|
|
return new Promise<string>((res, rej) => {
|
|
|
|
exec(command, (err, stdout, _stderr) => {
|
|
|
|
if (err) return rej(err)
|
2017-09-07 09:27:35 -04:00
|
|
|
|
2021-07-05 10:37:50 -04:00
|
|
|
return res(stdout)
|
|
|
|
})
|
2017-09-07 09:27:35 -04:00
|
|
|
})
|
2021-07-05 10:37:50 -04:00
|
|
|
}
|
2017-09-07 09:27:35 -04:00
|
|
|
|
2021-07-05 10:37:50 -04:00
|
|
|
getEnv () {
|
|
|
|
return `NODE_ENV=test NODE_APP_INSTANCE=${this.server.internalServerNumber}`
|
|
|
|
}
|
|
|
|
|
|
|
|
async execWithEnv (command: string) {
|
|
|
|
return CLICommand.exec(`${this.getEnv()} ${command}`)
|
|
|
|
}
|
|
|
|
}
|
2017-09-07 09:27:35 -04:00
|
|
|
|
|
|
|
export {
|
2021-07-05 10:37:50 -04:00
|
|
|
CLICommand
|
2017-09-07 09:27:35 -04:00
|
|
|
}
|