Added a script for updating the mod

This commit is contained in:
2025-07-15 18:29:58 +03:00
parent ccd2e4c994
commit c0c27830aa
2 changed files with 28 additions and 0 deletions

2
update.bat Normal file
View File

@@ -0,0 +1,2 @@
@echo off
powershell -ExecutionPolicy Bypass -File "%~dp0update.ps1"

26
update.ps1 Normal file
View File

@@ -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