mirror of
https://github.com/sinbad/UEScripts.git
synced 2025-02-23 13:15:23 +00:00
40 lines
935 B
PowerShell
40 lines
935 B
PowerShell
|
|
||
|
|
||
|
class PluginConfig {
|
||
|
[string]$OutputDir
|
||
|
|
||
|
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)
|
||
|
|
||
|
}
|