forked from engineering/cloudservices
More stuff
parent
1aeb51eb7a
commit
6e7845b052
|
@ -33,16 +33,15 @@ export default class Util {
|
||||||
*/
|
*/
|
||||||
public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> {
|
public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
let error = false;
|
|
||||||
let output = '';
|
let output = '';
|
||||||
const writeFunction = (data: string|Buffer|Error) => {
|
const writeFunction = (data: string|Buffer|Error) => {
|
||||||
if (data instanceof Error) error = true;
|
|
||||||
output += `${data}`;
|
output += `${data}`;
|
||||||
};
|
};
|
||||||
const cmd = childProcess.exec(command, options);
|
const cmd = childProcess.exec(command, options);
|
||||||
cmd.stdout.on('data', writeFunction);
|
cmd.stdout.on('data', writeFunction);
|
||||||
cmd.stderr.on('data', writeFunction);
|
cmd.stderr.on('data', writeFunction);
|
||||||
cmd.on('error', 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.once('close', (code, signal) => {
|
||||||
cmd.stdout.off('data', writeFunction);
|
cmd.stdout.off('data', writeFunction);
|
||||||
cmd.stderr.off('data', writeFunction);
|
cmd.stderr.off('data', writeFunction);
|
||||||
|
|
Loading…
Reference in New Issue