Skip to content

Commit 378e503

Browse files
committed
Update install script and readme for windows
1 parent 02bb4fa commit 378e503

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ Shell Installation (Mac, Linux)
1212
curl -fsSL https://raw.githubusercontent.com/laureanray/clibgen/main/install.sh | sh
1313
```
1414

15-
PowerShell Installation (Work in progress)
15+
PowerShell Installation (Windows)
16+
```powershell
17+
iwr https://raw.githubusercontent.com/laureanray/clibgen/main/install.sh -useb | iex
18+
```
19+
20+
Manual Installation (Binaries)
21+
- Download the file for your platform and version you need in the [releases page](https://github.com/laureanray/clibgen/releases)
22+
- Extract to where you store your binaries
23+
- Add the binaries directory to your PATH
1624

1725
### Usage
1826

install.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env pwsh
2+
# Copyright 2022 Laurean Ray Bahala. All rights reserved. MIT license.
3+
# TODO(everyone): Keep this script simple and easily auditable.
4+
5+
$ErrorActionPreference = 'Stop'
6+
7+
if ($v) {
8+
$Version = "v${v}"
9+
}
10+
if ($args.Length -eq 1) {
11+
$Version = $args.Get(0)
12+
}
13+
14+
$ClibgenInstall = $env:CLIBGEN_INSTALL
15+
$BinDir = if ($ClibgenInstall) {
16+
"$ClibgenInstall\bin"
17+
} else {
18+
"$Home\.clibgen\bin"
19+
}
20+
21+
$ClibgenZip = "$BinDir\clibgen.zip"
22+
$ClibgenExe = "$BinDir\clibgen.exe"
23+
$Target = 'Windows-x86_64'
24+
25+
# GitHub requires TLS 1.2
26+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
27+
28+
$ClibgenUri = if (!$Version) {
29+
"https://github.com/laureanray/clibgen/releases/latest/download/clibgen_${Target}.zip"
30+
} else {
31+
"https://github.com/laureanray/clibgen/releases/download/${Version}/clibgen_${Target}.zip"
32+
}
33+
34+
Write-Output $ClibgenUri
35+
36+
if (!(Test-Path $BinDir)) {
37+
New-Item $BinDir -ItemType Directory | Out-Null
38+
}
39+
40+
curl.exe -Lo $ClibgenZip $ClibgenUri
41+
42+
tar.exe xf $ClibgenZip -C $BinDir
43+
44+
Remove-Item $ClibgenZip
45+
46+
$User = [EnvironmentVariableTarget]::User
47+
$Path = [Environment]::GetEnvironmentVariable('Path', $User)
48+
if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) {
49+
[Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User)
50+
$Env:Path += ";$BinDir"
51+
}
52+
53+
Write-Output "Clibgen was installed successfully to $ClibgenExe"
54+
Write-Output "Run 'clibgen --help' to get started"

0 commit comments

Comments
 (0)