mirror of
https://github.com/MAKS-IT-COM/maksit-hamode.git
synced 2026-08-15 11:08:10 +02:00
36 lines
894 B
PowerShell
36 lines
894 B
PowerShell
#requires -Version 7.0
|
|
#requires -PSEdition Core
|
|
|
|
function Get-ScriptSettings {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$ScriptDir,
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
[string]$SettingsFileName = 'scriptSettings.json'
|
|
)
|
|
|
|
$settingsPath = Join-Path $ScriptDir $SettingsFileName
|
|
|
|
if (-not (Test-Path -LiteralPath $settingsPath -PathType Leaf)) {
|
|
throw "Settings file not found: $settingsPath"
|
|
}
|
|
|
|
return Get-Content -LiteralPath $settingsPath -Raw | ConvertFrom-Json
|
|
}
|
|
|
|
function Assert-Command {
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Command
|
|
)
|
|
|
|
if (-not (Get-Command $Command -ErrorAction SilentlyContinue)) {
|
|
throw "Required command '$Command' is missing. Aborting."
|
|
}
|
|
}
|
|
|
|
Export-ModuleMember -Function Get-ScriptSettings, Assert-Command
|