Fixes recursive loop on first loading of Framework

This commit is contained in:
Lord Hepipud 2023-05-09 12:57:40 +02:00
parent 2772c888cc
commit ada2b4ce0e
4 changed files with 43 additions and 1 deletions

View file

@ -8,6 +8,21 @@
Manually enabling the feature is no longer required. Manually enabling the feature is no longer required.
#> #>
# Ensure we only load this module once
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
return;
}
if ($null -eq $Global:Icinga) {
$Global:Icinga = @{ };
}
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $TRUE);
} else {
$Global:Icinga.CacheBuilding = $TRUE;
}
# Ensures that VS Code is not generating the cache file # Ensures that VS Code is not generating the cache file
if ($null -ne $env:TERM_PROGRAM) { if ($null -ne $env:TERM_PROGRAM) {
Write-IcingaFrameworkCodeCache -DeveloperMode; Write-IcingaFrameworkCodeCache -DeveloperMode;
@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) { if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate; Copy-IcingaFrameworkCacheTemplate;
} }
$Global:Icinga.CacheBuilding = $FALSE;

View file

@ -132,7 +132,11 @@ function Write-IcingaFrameworkCodeCache()
[System.IO.File]::WriteAllLines($CacheFile, $CacheContent, (New-Object System.Text.UTF8Encoding $TRUE)); [System.IO.File]::WriteAllLines($CacheFile, $CacheContent, (New-Object System.Text.UTF8Encoding $TRUE));
Remove-IcingaFrameworkDependencyFile; $DependencyFile = Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'framework_dependencies.json';
if ((Test-Path $DependencyFile)) {
Remove-Item -Path $DependencyFile -Force | Out-Null;
}
if ($Global:Icinga.Protected.DeveloperMode) { if ($Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate; Copy-IcingaFrameworkCacheTemplate;

View file

@ -15,6 +15,10 @@ function New-IcingaEnvironmentVariable()
$Global:Icinga = @{ }; $Global:Icinga = @{ };
} }
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $FALSE);
}
# Session specific configuration for this shell # Session specific configuration for this shell
if ($Global:Icinga.ContainsKey('Private') -eq $FALSE) { if ($Global:Icinga.ContainsKey('Private') -eq $FALSE) {
$Global:Icinga.Add('Private', @{ }); $Global:Icinga.Add('Private', @{ });

View file

@ -8,6 +8,21 @@
Manually enabling the feature is no longer required. Manually enabling the feature is no longer required.
#> #>
# Ensure we only load this module once
if ($null -ne $Global:Icinga -And $Global:Icinga.ContainsKey('CacheBuilding') -And $Global:Icinga['CacheBuilding']) {
return;
}
if ($null -eq $Global:Icinga) {
$Global:Icinga = @{ };
}
if ($Global:Icinga.ContainsKey('CacheBuilding') -eq $FALSE) {
$Global:Icinga.Add('CacheBuilding', $TRUE);
} else {
$Global:Icinga.CacheBuilding = $TRUE;
}
# Ensures that VS Code is not generating the cache file # Ensures that VS Code is not generating the cache file
if ($null -ne $env:TERM_PROGRAM) { if ($null -ne $env:TERM_PROGRAM) {
Write-IcingaFrameworkCodeCache -DeveloperMode; Write-IcingaFrameworkCodeCache -DeveloperMode;
@ -22,3 +37,5 @@ Import-Module icinga-powershell-framework -Force;
if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) { if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) {
Copy-IcingaFrameworkCacheTemplate; Copy-IcingaFrameworkCacheTemplate;
} }
$Global:Icinga.CacheBuilding = $FALSE;