Skip to content

Commit 4c65936

Browse files
author
Bruce Payette
authored
Merge pull request PowerShell#58 from sethvs/shouldProcess
Fix ShouldProcess for Add-WindowsPSModulePath
2 parents 83ec298 + f1edd5f commit 4c65936

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

WindowsCompatibility/WindowsCompatibility.psm1

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ function Add-WindowsPSModulePath
759759
)
760760

761761
$pathTable = [ordered] @{}
762-
$doUpdate = $false
762+
763763
foreach ($path in $paths)
764764
{
765765
if ($pathTable[$path])
@@ -770,14 +770,9 @@ function Add-WindowsPSModulePath
770770
if ($PSCmdlet.ShouldProcess($path, "Add to PSModulePath"))
771771
{
772772
Write-Verbose -Verbose:$verboseFlag "Adding '$path' to the PSModulePath."
773-
$doUpdate = $true
773+
$pathTable[$path] = $true
774774
}
775-
776-
$pathTable[$path] = $true
777775
}
778776

779-
if ($doUpdate)
780-
{
781-
$Env:PSModulePath = $pathTable.Keys -join [System.IO.Path]::PathSeparator
782-
}
777+
$Env:PSModulePath = $pathTable.Keys -join [System.IO.Path]::PathSeparator
783778
}

0 commit comments

Comments
 (0)