File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -203,16 +203,20 @@ Function Install-PSPackage() {
203203 $cmdlet
204204 )
205205 $module_path = " $bin_dir \$psm1_path .psm1"
206- if (-not (Test-Path $module_path - PathType Leaf)) {
207- $zip_file = " $bin_dir \$package .zip"
208- Get-File - Url $url - OutFile $zip_file
209- Expand-Archive - Path $zip_file - DestinationPath $bin_dir - Force
210- }
211- Import-Module $module_path
212- if ($null -eq (Get-Command $cmdlet - ErrorAction SilentlyContinue)) {
213- Install-Module - Name $package - Force
214- } else {
206+ $imported = $false
207+ try {
208+ if (-not (Test-Path $module_path - PathType Leaf)) {
209+ $zip_file = " $bin_dir \$package .zip"
210+ Get-File - Url $url - OutFile $zip_file
211+ Expand-Archive - Path $zip_file - DestinationPath $bin_dir - Force - ErrorAction Stop
212+ }
213+ Import-Module $module_path - ErrorAction Stop
214+ $imported = $null -ne (Get-Command $cmdlet - ErrorAction SilentlyContinue)
215+ } catch { }
216+ if ($imported ) {
215217 Add-ToProfile $current_profile " $package -search" " Import-Module $module_path "
218+ } else {
219+ Install-Module - Name $package - Force
216220 }
217221}
218222
You can’t perform that action at this time.
0 commit comments