mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-04-27 11:05:04 +07:00
Fix fallback in Install-PSPackage on Windows
This commit is contained in:
@@ -203,16 +203,20 @@ Function Install-PSPackage() {
|
||||
$cmdlet
|
||||
)
|
||||
$module_path = "$bin_dir\$psm1_path.psm1"
|
||||
$imported = $false
|
||||
try {
|
||||
if(-not (Test-Path $module_path -PathType Leaf)) {
|
||||
$zip_file = "$bin_dir\$package.zip"
|
||||
Get-File -Url $url -OutFile $zip_file
|
||||
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
||||
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force -ErrorAction Stop
|
||||
}
|
||||
Import-Module $module_path
|
||||
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
||||
Install-Module -Name $package -Force
|
||||
} else {
|
||||
Import-Module $module_path -ErrorAction Stop
|
||||
$imported = $null -ne (Get-Command $cmdlet -ErrorAction SilentlyContinue)
|
||||
} catch { }
|
||||
if($imported) {
|
||||
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
||||
} else {
|
||||
Install-Module -Name $package -Force
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user