Skip to content

Commit

Permalink
fix: install.ps1 for PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Oct 5, 2021
1 parent 80069f8 commit 2801600
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if (Test-Path C:\Windows\SysNative) {
}

$BinDir = "$Home\bin"
$is64Bit = Test-Path C:\Windows\SysNative
$WhatchangedTarGz = "$BinDir\whatchanged.tar.gz"
$WhatchangedExe = "$BinDir\whatchanged.exe"
$Target = "windows_$arch"
Expand All @@ -39,14 +38,35 @@ if (!(Test-Path $BinDir)) {

Invoke-WebRequest $ResourceUri -OutFile $WhatchangedTarGz -UseBasicParsing

if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) {
Expand-Archive $WhatchangedTarGz -Destination $BinDir -Force
function Check-Command {
param($Command)
$found = $false
try
{
$Command | Out-Null
$found = $true
}
catch [System.Management.Automation.CommandNotFoundException]
{
$found = $false
}

$found
}

if (Check-Command -Command tar) {
Invoke-Expression "tar -xvzf $WhatchangedTarGz -C $BinDir"
} else {
if (Test-Path $WhatchangedExe) {
Remove-Item $WhatchangedExe
function Expand-Tar($tarFile, $dest) {

if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) {
Install-Package -Scope CurrentUser -Force 7Zip4PowerShell > $null
}

Expand-7Zip $tarFile $dest
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($WhatchangedTarGz, $BinDir)

Expand-Tar $WhatchangedTarGz $BinDir
}

Remove-Item $WhatchangedTarGz
Expand Down

0 comments on commit 2801600

Please sign in to comment.