| 1 | # Match the production package smoke environment: inherited Reasonix overrides |
| 2 | # must not redirect state/cache writes or enable a development-only launch. |
| 3 | function Get-WindowsAcceptanceEnvironment { |
| 4 | $snapshot = @{} |
| 5 | foreach ($entry in Get-ChildItem Env:) { |
| 6 | if ($entry.Name -match '^REASONIX_|^(NODE_OPTIONS|ELECTRON_RUN_AS_NODE)$') { |
| 7 | $snapshot[$entry.Name] = $entry.Value |
| 8 | } |
| 9 | } |
| 10 | return $snapshot |
| 11 | } |
| 12 | |
| 13 | function Restore-WindowsAcceptanceEnvironment { |
| 14 | param([hashtable]$Snapshot) |
| 15 | foreach ($key in (Get-WindowsAcceptanceEnvironment).Keys) { |
| 16 | [Environment]::SetEnvironmentVariable($key, $null, 'Process') |
| 17 | } |
| 18 | foreach ($key in $Snapshot.Keys) { |
| 19 | [Environment]::SetEnvironmentVariable($key, $Snapshot[$key], 'Process') |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | function Enter-WindowsAcceptanceEnvironment { |
| 24 | param([Parameter(Mandatory=$true)][string]$DataHome) |
| 25 | $snapshot = Get-WindowsAcceptanceEnvironment |
| 26 | try { |
| 27 | foreach ($key in $snapshot.Keys) { |
| 28 | [Environment]::SetEnvironmentVariable($key, $null, 'Process') |
| 29 | } |
| 30 | $env:REASONIX_HOME = [IO.Path]::GetFullPath($DataHome) |
| 31 | $env:REASONIX_STATE_HOME = $env:REASONIX_HOME |
| 32 | $env:REASONIX_CACHE_HOME = Join-Path $env:REASONIX_HOME 'cache' |
| 33 | $env:REASONIX_NONINTERACTIVE = '1' |
| 34 | return $snapshot |
| 35 | } catch { |
| 36 | Restore-WindowsAcceptanceEnvironment -Snapshot $snapshot |
| 37 | throw |
| 38 | } |
| 39 | } |
| 40 |