mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-27 05:01:45 +00:00
copying files from existing release download
This commit is contained in:
parent
b297828c80
commit
6526d861d2
22
install.ps1
22
install.ps1
@ -16,6 +16,10 @@ if (Test-Path "$powershellPath\pwsh.exe")
|
|||||||
{ $powershellPath = "$powershellPath\powershell.exe"
|
{ $powershellPath = "$powershellPath\powershell.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Detect if current dir is release asset
|
||||||
|
$isRelease = Test-Path ".\ProxySwitcher.exe"
|
||||||
|
$releaseDir = (Get-Location).Path
|
||||||
|
|
||||||
# Create program directory and relocate
|
# Create program directory and relocate
|
||||||
Write-Host "Creating program directory in Userprofile..." -ForegroundColor Cyan
|
Write-Host "Creating program directory in Userprofile..." -ForegroundColor Cyan
|
||||||
$programDir = "ProxySwitcher"
|
$programDir = "ProxySwitcher"
|
||||||
@ -29,12 +33,20 @@ if ($startupDir -ne $destinationDir)
|
|||||||
Set-Location $programDir
|
Set-Location $programDir
|
||||||
$programPath = "$destinationDir\$programDir"
|
$programPath = "$destinationDir\$programDir"
|
||||||
|
|
||||||
# Download release files from github as-is
|
if ($isRelease)
|
||||||
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
{
|
||||||
Invoke-RestMethod https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.zip -OutFile $env:TMP
|
# Copy release assets to program dir
|
||||||
|
Write-Host "Copying program into local directory..." -ForegroundColor Cyan
|
||||||
|
Copy-Item -Path "$releaseDir\*" -Destination $programPath -Force
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
# Download release files from github as-is
|
||||||
|
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
||||||
|
Invoke-RestMethod https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.zip -OutFile $env:TMP
|
||||||
|
|
||||||
# Expand Archive to program directory
|
# Expand Archive to program directory
|
||||||
Expand-Archive "$env:TMP\ProxySwitcher.zip" -DestinationPath $programPath
|
Expand-Archive "$env:TMP\ProxySwitcher.zip" -DestinationPath $programPath
|
||||||
|
}
|
||||||
|
|
||||||
# Add program to PATH for cli application
|
# Add program to PATH for cli application
|
||||||
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
||||||
|
Loading…
Reference in New Issue
Block a user