-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstall-Zstd.ps1
29 lines (24 loc) · 1.01 KB
/
Install-Zstd.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
################################################################################
## File: Install-Zstd.ps1
## Desc: Install zstd
################################################################################
$downloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "facebook/zstd" `
-Version "latest" `
-UrlMatchPattern "zstd-*-win64.zip"
$zstdArchivePath = Invoke-DownloadWithRetry $downloadUrl
$zstdName = [IO.Path]::GetFileNameWithoutExtension($zstdArchivePath)
$toolPath = "C:\tools"
$zstdPath = Join-Path $toolPath zstd
$filesInArchive = 7z l $zstdArchivePath | Out-String
if ($filesInArchive.Contains($zstdName)) {
Expand-7ZipArchive -Path $zstdArchivePath -DestinationPath $toolPath
Invoke-ScriptBlockWithRetry -Command {
Move-Item -Path "${zstdPath}*" -Destination $zstdPath -ErrorAction Stop
}
} else {
Expand-7ZipArchive -Path $zstdArchivePath -DestinationPath $zstdPath
}
# Add zstd-win64 to PATH
Add-MachinePathItem $zstdPath
Invoke-PesterTests -TestFile "Tools" -TestName "Zstd"