1
0
Fork 0

More stuff

refactor/models
Bsian 2020-05-12 17:22:19 +01:00
parent 1aeb51eb7a
commit 6e7845b052
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 1 additions and 2 deletions

View File

@ -33,16 +33,15 @@ export default class Util {
*/
public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> {
return new Promise((res, rej) => {
let error = false;
let output = '';
const writeFunction = (data: string|Buffer|Error) => {
if (data instanceof Error) error = true;
output += `${data}`;
};
const cmd = childProcess.exec(command, options);
cmd.stdout.on('data', writeFunction);
cmd.stderr.on('data', writeFunction);
cmd.on('error', writeFunction);
cmd.on('error', (e) => this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(inspect(e))));
cmd.once('close', (code, signal) => {
cmd.stdout.off('data', writeFunction);
cmd.stderr.off('data', writeFunction);