fix: Made self update work on windows
This commit is contained in:
parent
cf84f40a17
commit
ae196e11d6
3 changed files with 24 additions and 4 deletions
|
|
@ -48,6 +48,10 @@ export default class SelfUpdateJob implements IJob<never, string>
|
||||||
{
|
{
|
||||||
case "win32":
|
case "win32":
|
||||||
validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.zip`).match(e.name));
|
validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.zip`).match(e.name));
|
||||||
|
if (!validAsset)
|
||||||
|
{
|
||||||
|
validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-*.zip`).match(e.name));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "linux":
|
case "linux":
|
||||||
validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.AppImage`).match(e.name));
|
validAsset = data.assets.find((e: any) => new Bun.Glob(`Gameflow-${process.platform}-${process.arch}.AppImage`).match(e.name));
|
||||||
|
|
@ -100,13 +104,13 @@ export default class SelfUpdateJob implements IJob<never, string>
|
||||||
const batPath = path.join(os.tmpdir(), "update-gameflow.bat");
|
const batPath = path.join(os.tmpdir(), "update-gameflow.bat");
|
||||||
await Bun.write(batPath, mustache.render(winUpdateScript, {
|
await Bun.write(batPath, mustache.render(winUpdateScript, {
|
||||||
tempFile: winDownloads[0],
|
tempFile: winDownloads[0],
|
||||||
extractDir: path.dirname(process.execPath),
|
installDir: path.dirname(process.execPath),
|
||||||
|
extractDir: path.join(os.tmpdir(), 'gameflow-update-extract'),
|
||||||
exePath: `${pkg.bin}.exe`
|
exePath: `${pkg.bin}.exe`
|
||||||
}));
|
}));
|
||||||
context.setProgress(0, "Restarting App To Update");
|
context.setProgress(0, "Restarting App To Update");
|
||||||
await cleanup();
|
|
||||||
events.emit('exitapp');
|
events.emit('exitapp');
|
||||||
Bun.spawn(["cmd", "/c", batPath], { detached: true });
|
Bun.spawn(["cmd", "/c", "start", "cmd", "/c", batPath], { detached: true });
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
echo "Waiting for app to close..."
|
||||||
sleep 2
|
sleep 2
|
||||||
|
echo "Installing update..."
|
||||||
mv "{{{tempFile}}}" "{{{appImagePath}}}"
|
mv "{{{tempFile}}}" "{{{appImagePath}}}"
|
||||||
chmod +x "{{{appImagePath}}}"
|
chmod +x "{{{appImagePath}}}"
|
||||||
|
echo "Done! Restarting..."
|
||||||
"{{{appImagePath}}}" &
|
"{{{appImagePath}}}" &
|
||||||
rm -- "$0"
|
rm -- "$0"
|
||||||
|
|
@ -1,6 +1,19 @@
|
||||||
@echo off
|
@echo off
|
||||||
|
echo Waiting for app to close...
|
||||||
timeout /t 2 /nobreak
|
timeout /t 2 /nobreak
|
||||||
powershell -Command "Expand-Archive -Force '{{{tempFile}}}' '{{{installDir}}}'"
|
echo.
|
||||||
|
if exist "{{{extractDir}}}" (
|
||||||
|
echo Cleaning up previous update files...
|
||||||
|
rmdir /S /Q "{{{extractDir}}}"
|
||||||
|
)
|
||||||
|
echo Extracting update...
|
||||||
|
mkdir "{{{extractDir}}}"
|
||||||
|
tar -xf "{{{tempFile}}}" -C "{{{extractDir}}}"
|
||||||
|
echo Installing update...
|
||||||
|
for /d %%i in ("{{{extractDir}}}\*") do xcopy /E /Y /I "%%i\*" "{{{installDir}}}\" >nul
|
||||||
|
echo Cleaning up...
|
||||||
|
rmdir /S /Q "{{{extractDir}}}"
|
||||||
del "{{{tempFile}}}"
|
del "{{{tempFile}}}"
|
||||||
|
echo Done! Restarting...
|
||||||
start "" /D "{{{installDir}}}" "{{{exePath}}}"
|
start "" /D "{{{installDir}}}" "{{{exePath}}}"
|
||||||
del "%~f0"
|
del "%~f0"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue