diff --git a/src/class/Util.ts b/src/class/Util.ts index 85d1c88..04b7627 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -2,6 +2,7 @@ import nodemailer from 'nodemailer'; import GoogleTTS, { TextToSpeechClient } from '@google-cloud/text-to-speech'; import childProcess from 'child_process'; +import { promisify } from 'util'; import ARIClient from 'ari-client'; import AMIClient from 'asterisk-manager'; import signale from 'signale'; @@ -48,7 +49,7 @@ export default class Util { this.ari = await ARIClient.connect('http://10.8.0.1:8088/ari', 'cr0', this.client.config.ariClientKey); this.ari.start(['cr-zero', 'page-dtmf']); - this.ami = new AMIClient(5038, '10.8.0.1', this.client.config.amiClientKey); + this.ami = new AMIClient(5038, '10.8.0.1', 'cr', this.client.config.amiClientKey); process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../google.json`; this.tts = new GoogleTTS.TextToSpeechClient(); @@ -84,8 +85,14 @@ export default class Util { } */ - public async exec(command: string, options: childProcess.ExecOptions = {}): Promise { - return new Promise((res, rej) => { + public async exec(command: string, _options: childProcess.ExecOptions = {}): Promise { + const ex = promisify(childProcess.exec); + try { + return (await ex(command)).stdout; + } catch (err) { + return err; + } + /* return new Promise((res, rej) => { let output = ''; const writeFunction = (data: string|Buffer|Error) => { output += `${data}`; @@ -102,7 +109,7 @@ export default class Util { if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`)); res(output); }); - }); + }); */ } /**