-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
34 lines (29 loc) · 1005 Bytes
/
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
param (
[Alias('v')]
[string] $Version,
[switch] $NoClean,
[switch] $NoPublish,
[string] $InfoPath = "config/buildinfo.json",
[string] $SourceFolder = "src"
)
$buildInfo = Get-Content "$InfoPath" -Encoding ASCII| ConvertFrom-Json
if (-not [string]::IsNullOrWhiteSpace($Version))
{
$buildInfo.info.version = $Version
}
$resolvedPath = Resolve-Path $buildInfo.output_directory
$modsDir = $resolvedPath.ToString()
if(!$NoClean) {
$glob = "$modsDir\" + $buildInfo.info.name + "_*"
$oldDirs = Get-ChildItem -Path $glob -Name
foreach ($dir in $oldDirs)
{
Remove-Item "$modsDir\$dir" -Recurse
}
}
if (!$NoPublish) {
$newDir = "$modsDir\" + $buildInfo.info.name + "_" + $buildInfo.info.version
Write-Output "$newDir"
Copy-Item -Path "$SourceFolder" -Recurse -Destination "$newDir"
ConvertTo-Json $buildInfo.info | ForEach-Object { [System.Text.RegularExpressions.Regex]::Unescape($_) } | Set-Content "$newDir\info.json" -Encoding UTF8
}