From c0c27830aa95e95182728c7c970ef467051b0175 Mon Sep 17 00:00:00 2001 From: HypoxiE Date: Tue, 15 Jul 2025 18:29:58 +0300 Subject: [PATCH] Added a script for updating the mod --- update.bat | 2 ++ update.ps1 | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 update.bat create mode 100644 update.ps1 diff --git a/update.bat b/update.bat new file mode 100644 index 0000000..888e57a --- /dev/null +++ b/update.bat @@ -0,0 +1,2 @@ +@echo off +powershell -ExecutionPolicy Bypass -File "%~dp0update.ps1" \ No newline at end of file diff --git a/update.ps1 b/update.ps1 new file mode 100644 index 0000000..0540ca2 --- /dev/null +++ b/update.ps1 @@ -0,0 +1,26 @@ +# Указываем ссылки и пути +$repoUrl = "https://github.com/HypoxiE/rimworld-add-my-music-mod/archive/refs/heads/main.zip" +$zipPath = "$env:TEMP\add_my_music.zip" +$extractPath = "$env:TEMP\add_my_music_temp" + +# Скачиваем и распаковываем архив +Write-Host "[INFO] Downloading mod from GitHub..." +Invoke-WebRequest -Uri $repoUrl -OutFile $zipPath +Write-Host "[INFO] Extracting..." +Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force + +# список исключений (имена без пути) +$keepFolders = @(".git", "Defs", "Sounds") +$keepFiles = @() + +Write-Host "[INFO] Uninstall old files..." +Get-ChildItem -Path $path -Directory | Where-Object { $keepFolders -notcontains $_.Name } | Remove-Item -Recurse -Force +Get-ChildItem -Path $path -File | Where-Object { $keepFiles -notcontains $_.Name } | Remove-Item -Force + +Write-Host "[INFO] Installing new files..." +Copy-Item -Path "$extractPath\rimworld-add-my-music-mod-main\*" -Destination "." -Recurse -Force + +# Удаляем временные файлы +Write-Host "[INFO] Cleaning up..." +Remove-Item $zipPath +Remove-Item $extractPath -Recurse -Force \ No newline at end of file