Fixed perfromance and a bug

This commit is contained in:
Gal Szkolnik 2021-10-29 14:33:25 -04:00
parent b0ec8e1780
commit b1a24fde1a
2 changed files with 7 additions and 3 deletions

View File

@ -79,7 +79,12 @@ catch {
Join-Path $(Join-Path $PackagePath profile.d) 'classes.ps1' |
Where-Object { Test-Path $_ } | ForEach-Object { . $_ }
}
$local:myPackages = Get-MyPackages -ReturnFullPath -IncludeRoot | Get-Item
# This is a hack that for some reason reduces (at least on one machine)
# this next line from running over 27 seconds, to under 5 seconds.
Invoke-Expression "function __GetMyPackages{$(Get-Content $(Join-Path $(Join-Path $MyPSScriptRoot "base") "Get-MyPackages.ps1") | Out-String )}"
$local:myPackages = __GetMyPackages -ReturnFullPath -IncludeRoot | Get-Item
Remove-Item function:__GetMyPackages
$local:myAliases = [ordered]@{}

View File

@ -28,7 +28,6 @@ class Packagesz { #: System.Management.Automation.IValidateSetValuesGenerator {
$local:currentSys = [SystemName]::_GetValidValues('',$true,$true);
$local:hostname = $(hostname)
$local:allCmdlets = Get-Command -ListImported | Select-Object -ExpandProperty Name -Unique
$local:allModules = Get-Module -ListAvailable | Select-Object -ExpandProperty Name -Unique
$local:username = $( if( $env:USER ) { $env:USER } else { $env:USERNAME } )
@ -49,7 +48,7 @@ class Packagesz { #: System.Management.Automation.IValidateSetValuesGenerator {
$v = $v -and -not $($c.CmdletExists | Where-Object { $allCmdlets -notcontains $_ })
}
if( $v -and $c.ModuleExists ) {
$v = $v -and -not $($c.ModuleExists | Where-Object { $allModules -notcontains $_ })
$v = $v -and -not $($c.ModuleExists | Where-Object { -not (Get-Module -ListAvailable $_ -ErrorAction Ignore) })
}
if( $v -and $c.AppExeExists ) {
$v = $v -and -not $($c.AppExeExists | Where-Object {