More stuff
parent
1aeb51eb7a
commit
6e7845b052
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue