mirror of
https://github.com/sinbad/UEScripts.git
synced 2025-02-23 05:05:24 +00:00
43 lines
1009 B
PowerShell
43 lines
1009 B
PowerShell
|
|
|
|
class PluginConfig {
|
|
[string]$PackageDir
|
|
[string]$BuildDir
|
|
[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)
|
|
|
|
}
|