forked from engineering/cloudservices
Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices
commit
a6b81139a3
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue