Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices

merge-requests/4/head
Matthew 2020-05-17 06:31:43 -04:00
commit a6b81139a3
No known key found for this signature in database
GPG Key ID: D499B75C1390E321
2 changed files with 7 additions and 8 deletions

View File

@ -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<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);
@ -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);
});
});

View File

@ -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);
}