-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
49 lines (40 loc) · 1.54 KB
/
build.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
46
47
48
49
#!pwsh
#Requires -Version 6
function local:rebuild()
{
$local:ErrorActionPreference = ([System.Management.Automation.ActionPreference]::Stop)
$moddir = Get-Item "$PSScriptRoot"
$modName = $moddir.basename
$modJson = Get-Item $moddir\mod.json
$tmpZipDirPath = "$ENV:TEMP\${modname}-zip"
if (Test-Path $tmpZipDirPath) { Remove-Item -Force -Recurse -Verbose $tmpZipDirPath }
mkdir $tmpZipDirPath
$tmpZipDir = Get-Item $tmpZipDirPath
$tmpZipModContentDir = "${tmpZipDir}\MOD_CONTENT\$modname"
$customModInstallDir = "C:\csquad\user\mods\$modName"
$modInstallDir =
if(Test-Path $customModInstallDir -PathType Container)
{
$customModInstallDir
}
else # Default expected user path for windows
{
"$ENV:APPDATA\Godot\app_userdata\Cruelty Squad\mods"
}
$copyExcludes = Write-Output .git media mod.zip mod.json $tmpZipDir
Copy-Item -Recurse -Verbose -Exclude $copyExcludes "$modDir" "$tmpZipModContentDir\"
$modZipOutPath = "$modInstallDir\mod.zip"
if (Test-Path $modZipOutPath) { Remove-Item -Verbose $modZipOutPath }
[System.IO.Compression.ZipFile]::CreateFromDirectory($tmpZipdir, $modZipOutPath)
Copy-Item -v -Force $modJSON $modInstallDir
if (Test-Path $modZipOutPath)
{
Write-Host -ForegroundColor Green 'Complete.'
Remove-Item -Recurse -Force -Verbose $tmpZipDir
}
else
{
Write-Error "Expected mod.zip not found: $($PSStyle.Underline)$modZipOutPath$($PSStyle.UnderlineOff)"
}
}
rebuild