From a1bd340d984d2f47418e3d034cbbb989e502aaab Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:21:26 +0100 Subject: [PATCH 01/11] Reject with error --- src/class/Util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 851337d..ae9547e 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -47,7 +47,7 @@ export default class Util { cmd.stdout.removeListener('data', writeFunction); cmd.stderr.removeListener('data', writeFunction); cmd.removeListener('error', writeFunction); - if (error) rej(output); + if (error) rej(new Error(output)); res(output); }); }); From e523e277e7880ca84872ab67d6e7eba1064edffc Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:24:06 +0100 Subject: [PATCH 02/11] Return the correct message --- src/commands/pull.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); } From 0a6984511028d335f40a2ae6a82c20e4a48709a0 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:34:01 +0100 Subject: [PATCH 03/11] Check something --- src/class/Util.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/class/Util.ts b/src/class/Util.ts index ae9547e..887bcc5 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -37,6 +37,7 @@ export default class Util { let output = ''; const writeFunction = (data: string|Buffer|Error) => { if (data instanceof Error) error = true; + if (data instanceof Error) this.client.getDMChannel('253600545972027394').then((c) => c.createMessage('error')); output += `${data}`; }; const cmd = childProcess.exec(command, options); From 14642536756774d156caf9eca5e5a7f1afcb4195 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:37:23 +0100 Subject: [PATCH 04/11] Test --- src/class/Util.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 887bcc5..6192141 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'; @@ -38,6 +38,7 @@ export default class Util { const writeFunction = (data: string|Buffer|Error) => { if (data instanceof Error) error = true; if (data instanceof Error) this.client.getDMChannel('253600545972027394').then((c) => c.createMessage('error')); + this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(inspect(data, { depth: 0 }))); output += `${data}`; }; const cmd = childProcess.exec(command, options); From 0ba05afa66bd275b648188d18387224e3920fcd8 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:42:13 +0100 Subject: [PATCH 05/11] dunno what's happening --- src/class/Util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 6192141..ea7e228 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -38,7 +38,7 @@ export default class Util { const writeFunction = (data: string|Buffer|Error) => { if (data instanceof Error) error = true; if (data instanceof Error) this.client.getDMChannel('253600545972027394').then((c) => c.createMessage('error')); - this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(inspect(data, { depth: 0 }))); + this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(data.toString())); output += `${data}`; }; const cmd = childProcess.exec(command, options); From d098ac1832269717a6ddc881fe69a7f94ab59dbf Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 16:46:19 +0100 Subject: [PATCH 06/11] change names --- src/class/Util.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index ea7e228..25819f2 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -46,9 +46,9 @@ 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); + cmd.stdout.off('data', writeFunction); + cmd.stderr.off('data', writeFunction); + cmd.off('error', writeFunction); if (error) rej(new Error(output)); res(output); }); From 1aeb51eb7aefa3328f609c8a6bc720e3a1611682 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 17:10:34 +0100 Subject: [PATCH 07/11] Attempt at a fix? --- src/class/Util.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 25819f2..a79c0cc 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -37,8 +37,6 @@ export default class Util { let output = ''; const writeFunction = (data: string|Buffer|Error) => { if (data instanceof Error) error = true; - if (data instanceof Error) this.client.getDMChannel('253600545972027394').then((c) => c.createMessage('error')); - this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(data.toString())); output += `${data}`; }; const cmd = childProcess.exec(command, options); @@ -49,7 +47,7 @@ export default class Util { cmd.stdout.off('data', writeFunction); cmd.stderr.off('data', writeFunction); cmd.off('error', writeFunction); - if (error) rej(new Error(output)); + if (code !== 0) rej(new Error(output)); res(output); }); }); From 6e7845b05202d2ec0a69e54d8df58fe1c9d92e94 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 17:22:19 +0100 Subject: [PATCH 08/11] More stuff --- src/class/Util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index a79c0cc..d8cbebd 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -33,16 +33,15 @@ 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); 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); From 60971038d4dcaaf1a6c61a3b80cd9ea51e1c5192 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 17:26:39 +0100 Subject: [PATCH 09/11] Timeout --- src/class/Util.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/class/Util.ts b/src/class/Util.ts index d8cbebd..f40b212 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -46,6 +46,7 @@ export default class Util { cmd.stdout.off('data', writeFunction); cmd.stderr.off('data', writeFunction); cmd.off('error', writeFunction); + setTimeout(() => {}, 1000); if (code !== 0) rej(new Error(output)); res(output); }); From 18267b8a0aa6acd4ba93d696507da1978b650629 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 17:27:12 +0100 Subject: [PATCH 10/11] depth 0 --- src/class/Util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index f40b212..829f496 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -41,7 +41,7 @@ export default class Util { 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.on('error', (e) => this.client.getDMChannel('253600545972027394').then((c) => c.createMessage(inspect(e, { depth: 0 })))); cmd.once('close', (code, signal) => { cmd.stdout.off('data', writeFunction); cmd.stderr.off('data', writeFunction); From 10d2fbb374c15387cefdb466eae4457679e69889 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 12 May 2020 17:32:46 +0100 Subject: [PATCH 11/11] This is a bodge fix --- src/class/Util.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 829f496..d4fece4 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -41,13 +41,12 @@ export default class Util { 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, { depth: 0 })))); cmd.once('close', (code, signal) => { cmd.stdout.off('data', writeFunction); cmd.stderr.off('data', writeFunction); cmd.off('error', writeFunction); setTimeout(() => {}, 1000); - if (code !== 0) rej(new Error(output)); + if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`)); res(output); }); });