diff --git a/src/class/Util.ts b/src/class/Util.ts index 851337d..d4fece4 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -1,5 +1,5 @@ /* eslint-disable no-param-reassign */ -import { promisify } from 'util'; +import { promisify, inspect } from 'util'; import childProcess from 'child_process'; import nodemailer from 'nodemailer'; import { Message, PrivateChannel, GroupChannel, Member, User } from 'eris'; @@ -33,10 +33,8 @@ export default class Util { */ public async exec(command: string, options: childProcess.ExecOptions = {}): Promise { 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); @@ -44,10 +42,11 @@ export default class Util { cmd.stderr.on('data', writeFunction); cmd.on('error', writeFunction); cmd.once('close', (code, signal) => { - cmd.stdout.removeListener('data', writeFunction); - cmd.stderr.removeListener('data', writeFunction); - cmd.removeListener('error', writeFunction); - if (error) rej(output); + cmd.stdout.off('data', writeFunction); + cmd.stderr.off('data', writeFunction); + cmd.off('error', writeFunction); + setTimeout(() => {}, 1000); + if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`)); res(output); }); }); diff --git a/src/commands/pull.ts b/src/commands/pull.ts index 7639315..9a4c8f5 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -61,7 +61,7 @@ export default class Pull extends Command { updatedPackages = await updateMessage.edit(updatedMessage); } else { const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Unexpected yarn install output***\n` - + `\`\`\`\n${pull}\n\`\`\``); + + `\`\`\`\n${install}\n\`\`\``); this.client.updating = false; return updateMessage.edit(updatedMessage); }