Merge pull request #279 from mlocati/win32/use-powershell-phpmanager-release-assets

Download release assets for PowerShell PhpManager
This commit is contained in:
Shivam Mathur 2020-08-25 23:22:57 +05:30
commit 83019fade2
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -75,13 +75,12 @@ Function Get-CleanPSProfile {
# Function to install PhpManager. # Function to install PhpManager.
Function Install-PhpManager() { Function Install-PhpManager() {
$repo = "mlocati/powershell-phpmanager" $module_path = "$bin_dir\PhpManager\PhpManager.psm1"
$tag = (Invoke-RestMethod https://api.github.com/repos/$repo/releases/latest).tag_name
$module_path = "$bin_dir\PhpManager\powershell-phpmanager-$tag\PhpManager\PhpManager.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { if(-not (Test-Path $module_path -PathType Leaf)) {
$release = Invoke-RestMethod https://api.github.com/repos/mlocati/powershell-phpmanager/releases/latest
$zip_file = "$bin_dir\PhpManager.zip" $zip_file = "$bin_dir\PhpManager.zip"
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir\PhpManager -Force Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
} }
Import-Module $module_path Import-Module $module_path
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path" Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path"