Improve performance of Package identification
Using -ListAvailable with Get-Command to ensure no module loading is attampeted while querying loaded commands. This improved performance when certain modules have not been loaded yet
This commit is contained in:
parent
499a86baa6
commit
22aa3ba435
10 changed files with 17 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
|||
if( -not (Get-Command Join-String -ErrorAction SilentlyContinue) ) {
|
||||
if( -not (Get-Command -ListImported Join-String -ErrorAction SilentlyContinue) ) {
|
||||
if( -not (Get-Module -ListAvailable -Name "string") ) {
|
||||
Write-Warning 'Join-String Command is missing, attempting to install stirng module'
|
||||
$local:moduleScope = "CurrentUser"
|
|
@ -15,7 +15,7 @@ if( Get-Module PowerShellCookbook ) {
|
|||
Import-Module PowerShellCookbook -Cmdlet Add-ObjectCollector
|
||||
}
|
||||
#
|
||||
. Get-Command Add-ObjectCollector -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Add-ObjectCollector
|
||||
Get-Item function:/Add-ObjectCollector | Remove-Item
|
||||
}
|
||||
. Get-Command -ListImported Add-ObjectCollector -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
Add-ObjectCollector
|
||||
Get-Item function:/Add-ObjectCollector | Remove-Item
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class FunctionName { #: System.Management.Automation.IValidateSetValuesGenerator {
|
||||
static [string[]] _GetValidValues([string]$wordToComplete,[bool]$Strict) {
|
||||
$local:possibleValues = Get-Command -Type Function | Select-Object -ExpandProperty Name
|
||||
$local:possibleValues = Get-Command -ListImported -Type Function | Select-Object -ExpandProperty Name
|
||||
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $possibleValues -Strict:$Strict );
|
||||
}
|
||||
static [String[]] _GetValidValues([string]$wordToComplete,[switch]$Strict) {
|
||||
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $(Get-Command -Type Function | Select-Object -ExpandProperty Name) -Strict:$Strict)
|
||||
return $(Get-PossibleArguments -WordToComplete $wordToComplete -FullValueSet $(Get-Command -ListImported -Type Function | Select-Object -ExpandProperty Name) -Strict:$Strict)
|
||||
# $local:possibleValues =
|
||||
# if( $wordToComplete ) {
|
||||
# $possibleValues = $possibleValues | Where-Object { $_ -match $wordToComplete }
|
||||
|
|
|
@ -3,13 +3,13 @@ $global:IsOutputANSICompatible = (
|
|||
) -or (
|
||||
($env:ConEmuANSI -eq 'ON') -and ($Host.Name -eq 'ConsoleHost' )
|
||||
)
|
||||
Get-Command Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
|
||||
Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
|
||||
ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
|
||||
if( (Get-Command Set-PoshPrompt -ErrorAction SilentlyContinue) -and $IsOutputANSICompatible ) {
|
||||
if( (Get-Command -ListImported Set-PoshPrompt -ErrorAction SilentlyContinue) -and $IsOutputANSICompatible ) {
|
||||
$local:poshPrompt = Join-Path $HOME ".oh-my-posh.omp.json"
|
||||
if( -not (Test-Path $poshPrompt) ) { $poshPrompt = "slim" }
|
||||
Set-PoshPrompt -Theme $poshPrompt
|
||||
} elseif( Get-Command Set-Theme -ErrorAction SilentlyContinue ) {
|
||||
} elseif( Get-Command -ListImported Set-Theme -ErrorAction SilentlyContinue ) {
|
||||
Set-Theme Paradox
|
||||
} elseif( Get-Module -ListAvailable posh-git -ErrorAction SilentlyContinue ) {
|
||||
Import-Module posh-git
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue