Skip to content

Commit

Permalink
Fix module installation in PowerShell 3 and 4 (pester#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
fflaten authored Oct 3, 2022
1 parent ca86dcd commit 21bde32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Pester.Runtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2502,9 +2502,9 @@ function Import-Dependency {
# that script block, and then we dot source it again to import it
# into the caller scope, effectively defining the functions there
$sb = {
param ($p)
param ($p, $private:Remove_Variable)

. $($p; & $SafeCommands['Remove-Variable'] -Scope Local -Name p)
. $($p; & $private:Remove_Variable -Scope Local -Name p)
}

$flags = [System.Reflection.BindingFlags]'Instance,NonPublic'
Expand All @@ -2515,7 +2515,7 @@ function Import-Dependency {
$sb.GetType().GetProperty('SessionStateInternal', $flags).SetValue($sb, $SessionStateInternal, $null)

# dot source the caller bound scriptblock which imports it into user scope
. $sb $Dependency
. $sb $Dependency $SafeCommands['Remove-Variable']
}
}

Expand Down

0 comments on commit 21bde32

Please sign in to comment.