fix(pwsh): export outside functions as global

relates to #2318
This commit is contained in:
Jan De Dobbeleer 2022-05-25 20:23:16 +02:00 committed by Jan De Dobbeleer
parent b6ac0b3904
commit 74b8a094e7

View file

@ -5,7 +5,7 @@ if ($null -ne (Get-Module -Name "oh-my-posh-core")) {
# Helper functions which need to be defined before the module is loaded # Helper functions which need to be defined before the module is loaded
# See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2300 # See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2300
function Get-PoshStackCount { function global:Get-PoshStackCount {
$locations = Get-Location -Stack $locations = Get-Location -Stack
if ($locations) { if ($locations) {
return $locations.Count return $locations.Count
@ -14,7 +14,7 @@ function Get-PoshStackCount {
} }
# See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/1928 # See https://github.com/JanDeDobbeleer/oh-my-posh/discussions/1928
function Test-PSDebugContext { return Test-Path Variable:/PSDebugContext } function global:Test-PSDebugContext { return Test-Path Variable:/PSDebugContext }
New-Module -Name "oh-my-posh-core" -ScriptBlock { New-Module -Name "oh-my-posh-core" -ScriptBlock {
$script:ErrorCode = 0 $script:ErrorCode = 0
@ -258,7 +258,7 @@ Example:
$script:TransientPrompt = $false $script:TransientPrompt = $false
return return
} }
if (Test-PSDebugContext) { if (global:Test-PSDebugContext) {
@(Start-Utf8Process $script:OMPExecutable @("print", "debug", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--shell=::SHELL::")) -join "`n" @(Start-Utf8Process $script:OMPExecutable @("print", "debug", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--config=$env:POSH_THEME", "--shell=::SHELL::")) -join "`n"
return return
} }
@ -286,7 +286,7 @@ Example:
} }
} }
$stackCount = Get-PoshStackCount $stackCount = global:Get-PoshStackCount
Set-PoshContext Set-PoshContext
$terminalWidth = $Host.UI.RawUI.WindowSize.Width $terminalWidth = $Host.UI.RawUI.WindowSize.Width
# set a sane default when the value can't be retrieved # set a sane default when the value can't be retrieved