Don't restart if build error

merge-requests/1/merge
Bsian 2019-11-30 23:55:49 +00:00
parent 7bc601b685
commit 495159336b
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
2 changed files with 4 additions and 0 deletions

View File

@ -14,6 +14,7 @@ export default class Pull extends Command {
public async run(message: Message) { public async run(message: Message) {
try { try {
if (this.client.updating) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Update in progress***`);
this.client.updating = true; this.client.updating = true;
const updateMessage = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Fetching latest commit...***\n\`\`\`sh\ngit pull\n\`\`\``); const updateMessage = await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Fetching latest commit...***\n\`\`\`sh\ngit pull\n\`\`\``);
let pull: string; let pull: string;
@ -74,12 +75,14 @@ export default class Pull extends Command {
} catch (error) { } catch (error) {
const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***`) const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***`)
.replace(/```$/, `${error.message}\n\`\`\``); .replace(/```$/, `${error.message}\n\`\`\``);
this.client.buildError = true;
this.client.updating = false; this.client.updating = false;
return updateMessage.edit(updatedMessage); return updateMessage.edit(updatedMessage);
} }
const finalMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.success} ***Files rebuilt***`) const finalMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.success} ***Files rebuilt***`)
.replace(/```$/, `${build}\n\`\`\``); .replace(/```$/, `${build}\n\`\`\``);
this.client.updating = false; this.client.updating = false;
this.client.buildError = false;
return updateMessage.edit(finalMessage); return updateMessage.edit(finalMessage);
} catch (error) { } catch (error) {
this.client.updating = false; this.client.updating = false;

View File

@ -14,6 +14,7 @@ export default class Restart extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
if (this.client.updating && args[0] !== '-f') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Update in progress***`); if (this.client.updating && args[0] !== '-f') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Update in progress***`);
if (this.client.buildError) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Build error, resolve before restarting***`);
await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Restarting...***`); await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Restarting...***`);
return process.exit(1); return process.exit(1);
} catch (error) { } catch (error) {