1
0
Fork 0

Don't restart if build error

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

View File

@ -14,6 +14,7 @@ export default class Restart extends Command {
public async run(message: Message, args: string[]) {
try {
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...***`);
return process.exit(1);
} catch (error) {