Add fallback to Install-PSPackage in win32.ps1

This commit is contained in:
Shivam Mathur 2021-04-18 05:08:38 +05:30
parent 45df3b1713
commit 7d9584bd3f
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -63,7 +63,9 @@ Function Install-PSPackage() {
[Parameter(Position = 1, Mandatory = $true)]
$psm1_path,
[Parameter(Position = 2, Mandatory = $true)]
$url
$url,
[Parameter(Position = 3, Mandatory = $true)]
$cmdlet
)
$module_path = "$php_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) {
@ -73,6 +75,10 @@ Function Install-PSPackage() {
}
Import-Module $module_path
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
Install-Module -Name $cmdlet -Force
}
}
Function Add-Extension {
@ -273,6 +279,9 @@ $composer_json = "$env:APPDATA\Composer\composer.json"
$composer_lock = "$env:APPDATA\Composer\composer.lock"
$master_version = '8.0'
$arch = 'x64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
$arch = 'x86'
}
$ts = $env:PHPTS -eq 'ts'
if($env:PHPTS -ne 'ts') {
$env:PHPTS = 'nts'
@ -283,7 +292,7 @@ if(-not(Test-Path -LiteralPath $current_profile)) {
Add-Printf >$null 2>&1
Step-Log "Setup PhpManager"
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" Get-Php >$null 2>&1
Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP"
@ -295,9 +304,8 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
}
$status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0') {
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
$arch='x86'
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
}
try {
if ($version -eq $master_version) {