Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices
commit
a6b81139a3
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
import { promisify } from 'util';
|
import { promisify, inspect } from 'util';
|
||||||
import childProcess from 'child_process';
|
import childProcess from 'child_process';
|
||||||
import nodemailer from 'nodemailer';
|
import nodemailer from 'nodemailer';
|
||||||
import { Message, PrivateChannel, GroupChannel, Member, User } from 'eris';
|
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> {
|
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);
|
||||||
|
@ -44,10 +42,11 @@ export default class Util {
|
||||||
cmd.stderr.on('data', writeFunction);
|
cmd.stderr.on('data', writeFunction);
|
||||||
cmd.on('error', writeFunction);
|
cmd.on('error', writeFunction);
|
||||||
cmd.once('close', (code, signal) => {
|
cmd.once('close', (code, signal) => {
|
||||||
cmd.stdout.removeListener('data', writeFunction);
|
cmd.stdout.off('data', writeFunction);
|
||||||
cmd.stderr.removeListener('data', writeFunction);
|
cmd.stderr.off('data', writeFunction);
|
||||||
cmd.removeListener('error', writeFunction);
|
cmd.off('error', writeFunction);
|
||||||
if (error) rej(output);
|
setTimeout(() => {}, 1000);
|
||||||
|
if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`));
|
||||||
res(output);
|
res(output);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,7 +61,7 @@ export default class Pull extends Command {
|
||||||
updatedPackages = await updateMessage.edit(updatedMessage);
|
updatedPackages = await updateMessage.edit(updatedMessage);
|
||||||
} else {
|
} else {
|
||||||
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Unexpected yarn install output***\n`
|
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;
|
this.client.updating = false;
|
||||||
return updateMessage.edit(updatedMessage);
|
return updateMessage.edit(updatedMessage);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue