UEScripts/inc/pluginconfig.ps1

43 lines
1009 B
PowerShell
Raw Permalink Normal View History

class PluginConfig {
[string]$PackageDir
[string]$BuildDir
2023-06-14 15:29:44 +01:00
[string]$PluginFile
[array]$EngineVersions
PluginConfig([PSCustomObject]$obj) {
# Construct from JSON object
# Override just properties that are set
$obj.PSObject.Properties | ForEach-Object {
try {
# Nested array dealt with below
$this.$($_.Name) = $_.Value
} catch {
Write-Host "Invalid property in plugin config: $($_.Name) = $($_.Value)"
}
}
}
}
# Read pluginconfig.json file from a source location and return PluginConfig instance
function Read-Plugin-Config {
param (
[string]$srcfolder
)
$configfile = Resolve-Path "$srcfolder\pluginconfig.json"
if (-not (Test-Path $configfile -PathType Leaf)) {
throw "$srcfolder\pluginconfig.json does not exist!"
}
$obj = (Get-Content $configfile) | ConvertFrom-Json
return [PluginConfig]::New($obj)
}