-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_update_en.ps1
45 lines (37 loc) · 1.26 KB
/
_update_en.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Write-Host "ItemTreasury Database EN updater"
$PathRun = $PSCommandPath | Split-Path -Parent
Write-Host "Current location [$PathRun]"
Set-Location -Path $PathRun
Write-Host "Check files"
function CheckAndPatch {
param($file, $pattern, $replace, $patch)
$LuaPatch = select-string -Path $file -Pattern $pattern
if ($LuaPatch) {
Write-Host "$file already patched"
}
else {
(Get-Content -Path $file) -replace $replace, $patch | Set-Content -Path $file
Write-Host "$file patched"
}
}
function download {
param($from, $to)
Write-Host "Start update $to"
Invoke-WebRequest -URI $from -OutFile $to
}
CheckAndPatch `
-file ".\Main.lua" `
-pattern 'import \(PLUGINDIR\.\."\.Items"\);' `
-replace 'import \(PLUGINDIR\.\."\.(.+)_Items"\);' `
-patch "import (PLUGINDIR..`".Items`");"
CheckAndPatch `
-file ".\Main.lua" `
-pattern 'import \(PLUGINDIR\.\."\.NewItems"\);' `
-replace 'import \(PLUGINDIR\.\."\.(.+)_NewItems"\);' `
-patch "import (PLUGINDIR..`".NewItems`");"
download `
-from "https://github.com/dt192/item-treasury-database/raw/patch/Items.lua" `
-to ".\Items.lua"
download `
-from "https://github.com/dt192/item-treasury-database/raw/patch/NewItems.lua" `
-to ".\NewItems.lua"