From c46b7c6ea6c81d6118a98d73b0a9f2725c075aeb Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 3 Mar 2024 22:02:27 -0500 Subject: [PATCH] Modified the self updater to reset any local changes when updating #10 --- client/modules/selfUpdater.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/modules/selfUpdater.mjs b/client/modules/selfUpdater.mjs index 28dbabe..a9e2799 100644 --- a/client/modules/selfUpdater.mjs +++ b/client/modules/selfUpdater.mjs @@ -18,6 +18,15 @@ export const checkForUpdates = async () => { if (latestCommitHash !== localCommitHash) { console.log('An update is available. Updating...'); + // Check if there have been any changes to the code + const gitStatus = await git.status() + console.log(gitStatus); + if (gitStatus.modified.length > 0){ + // There is locally modified code + console.log("There is locally modified code, resetting..."); + await git.reset('hard', ['origin/master']) + } + // Pull the latest changes from the remote repository await git.pull();