1
1
# PowerShell script to install docs-builder binary
2
2
3
3
# Use AppData\Local for user-specific installation instead of Program Files
4
- $targetDir = Join-Path - Path $env: LOCALAPPDATA - ChildPath " docs-builder"
4
+ $targetDir = Join-Path - Path $env: LOCALAPPDATA - ChildPath " docs-builder"
5
5
$targetPath = Join-Path - Path $targetDir - ChildPath " docs-builder.exe"
6
6
7
+ $version = $env: DOCS_BUILDER_VERSION
8
+ if (-not $version ) { $version = ' latest' }
9
+
7
10
# Check if docs-builder already exists
8
11
if (Test-Path - Path $targetPath ) {
9
12
Write-Host " docs-builder is already installed."
@@ -20,10 +23,15 @@ if (-not (Test-Path -Path $targetDir)) {
20
23
New-Item - ItemType Directory - Path $targetDir - Force | Out-Null
21
24
}
22
25
23
- # Download the latest Windows binary from releases
26
+ if ($version -eq ' latest' ) {
27
+ $downloadUrl = " https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip"
28
+ } else {
29
+ $downloadUrl = " https://github.com/elastic/docs-builder/releases/download/$version /docs-builder-win-x64.zip"
30
+ }
31
+
24
32
$tempZipPath = " $env: TEMP \docs-builder-win-x64.zip"
25
33
Write-Host " Downloading docs-builder binary..."
26
- Invoke-WebRequest - Uri " https://github.com/elastic/docs-builder/releases/latest/download/docs-builder-win-x64.zip " - OutFile $tempZipPath
34
+ Invoke-WebRequest - Uri $downloadUrl - OutFile $tempZipPath
27
35
28
36
# Create a temporary directory for extraction
29
37
$tempExtractPath = " $env: TEMP \docs-builder-extract"
@@ -53,8 +61,8 @@ if ($currentPath -notlike "*$targetDir*") {
53
61
}
54
62
55
63
# Clean up temporary files
56
- Remove-Item - Path $tempZipPath - Force
64
+ Remove-Item - Path $tempZipPath - Force
57
65
Remove-Item - Path $tempExtractPath - Recurse - Force
58
66
59
- Write-Host " docs-builder has been installed successfully and is available in your PATH."
60
- Write-Host " You may need to restart your terminal or PowerShell session for the PATH changes to take effect."
67
+ Write-Host " docs-builder ( $version ) has been installed successfully and is available in your PATH."
68
+ Write-Host " You may need to restart your terminal or PowerShell session for the PATH changes to take effect."
0 commit comments